xref: /AOO41X/main/xmloff/source/text/XMLTextFrameContext.cxx (revision 4d38e14b27d6f9fe9918fdefe233cbeb157c239c)
163bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
363bba73cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
463bba73cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
563bba73cSAndrew Rist  * distributed with this work for additional information
663bba73cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
763bba73cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
863bba73cSAndrew Rist  * "License"); you may not use this file except in compliance
963bba73cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
1163bba73cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
1363bba73cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
1463bba73cSAndrew Rist  * software distributed under the License is distributed on an
1563bba73cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1663bba73cSAndrew Rist  * KIND, either express or implied.  See the License for the
1763bba73cSAndrew Rist  * specific language governing permissions and limitations
1863bba73cSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
2063bba73cSAndrew Rist  *************************************************************/
2163bba73cSAndrew Rist 
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
241f882ec4SArmin Le Grand 
25cdf0e10cSrcweir #include <tools/debug.hxx>
26cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27cdf0e10cSrcweir #include <com/sun/star/text/TextContentAnchorType.hpp>
28cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
29cdf0e10cSrcweir #include <com/sun/star/text/XTextFrame.hpp>
30cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp>
31cdf0e10cSrcweir #include <com/sun/star/text/SizeType.hpp>
32cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp>
33cdf0e10cSrcweir #include <com/sun/star/document/XEventsSupplier.hpp>
34cdf0e10cSrcweir #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
35cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
36cdf0e10cSrcweir #include <com/sun/star/text/HoriOrientation.hpp>
37cdf0e10cSrcweir #include <com/sun/star/text/VertOrientation.hpp>
38cdf0e10cSrcweir #include <xmloff/xmlimp.hxx>
39cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
40cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
41cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
42cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
43cdf0e10cSrcweir #include "XMLAnchorTypePropHdl.hxx"
44cdf0e10cSrcweir #include "XMLEmbeddedObjectImportContext.hxx"
45cdf0e10cSrcweir #include <xmloff/XMLBase64ImportContext.hxx>
46cdf0e10cSrcweir #include "XMLReplacementImageContext.hxx"
47cdf0e10cSrcweir #include <xmloff/prstylei.hxx>
48cdf0e10cSrcweir #include "xmloff/i18nmap.hxx"
49cdf0e10cSrcweir #include "xexptran.hxx"
50cdf0e10cSrcweir #include <xmloff/shapeimport.hxx>
51cdf0e10cSrcweir #include <xmloff/XMLEventsImportContext.hxx>
52cdf0e10cSrcweir #include "XMLImageMapContext.hxx"
53cdf0e10cSrcweir #include "XMLTextFrameContext.hxx"
54cdf0e10cSrcweir #include "XMLTextListBlockContext.hxx"
55cdf0e10cSrcweir #include "XMLTextListItemContext.hxx"
56cdf0e10cSrcweir #include <xmloff/attrlist.hxx>
57cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
581f882ec4SArmin Le Grand #include <basegfx/polygon/b2dpolygon.hxx>
591f882ec4SArmin Le Grand #include <basegfx/polygon/b2dpolygontools.hxx>
601f882ec4SArmin Le Grand #include <basegfx/matrix/b2dhommatrixtools.hxx>
611f882ec4SArmin Le Grand #include <basegfx/polygon/b2dpolypolygontools.hxx>
62cdf0e10cSrcweir #include <map>
63cdf0e10cSrcweir 
64cdf0e10cSrcweir using ::rtl::OUString;
65cdf0e10cSrcweir using ::rtl::OUStringBuffer;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir using namespace ::com::sun::star;
68cdf0e10cSrcweir using namespace ::com::sun::star::uno;
69cdf0e10cSrcweir using namespace ::com::sun::star::text;
70cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax;
71cdf0e10cSrcweir using namespace ::com::sun::star::beans;
72cdf0e10cSrcweir using namespace ::com::sun::star::lang;
73cdf0e10cSrcweir using namespace ::com::sun::star::container;
74cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
75cdf0e10cSrcweir using namespace ::com::sun::star::document;
76cdf0e10cSrcweir using namespace ::xmloff::token;
77cdf0e10cSrcweir using ::com::sun::star::document::XEventsSupplier;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir #define XML_TEXT_FRAME_TEXTBOX 1
80cdf0e10cSrcweir #define XML_TEXT_FRAME_GRAPHIC 2
81cdf0e10cSrcweir #define XML_TEXT_FRAME_OBJECT 3
82cdf0e10cSrcweir #define XML_TEXT_FRAME_OBJECT_OLE 4
83cdf0e10cSrcweir #define XML_TEXT_FRAME_APPLET 5
84cdf0e10cSrcweir #define XML_TEXT_FRAME_PLUGIN 6
85cdf0e10cSrcweir #define XML_TEXT_FRAME_FLOATING_FRAME 7
86cdf0e10cSrcweir 
87cdf0e10cSrcweir typedef ::std::map < const ::rtl::OUString, ::rtl::OUString, ::comphelper::UStringLess> ParamMap;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir class XMLTextFrameContextHyperlink_Impl
90cdf0e10cSrcweir {
91cdf0e10cSrcweir     OUString sHRef;
92cdf0e10cSrcweir     OUString sName;
93cdf0e10cSrcweir     OUString sTargetFrameName;
94cdf0e10cSrcweir     sal_Bool bMap;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir public:
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     inline XMLTextFrameContextHyperlink_Impl( const OUString& rHRef,
99cdf0e10cSrcweir                        const OUString& rName,
100cdf0e10cSrcweir                        const OUString& rTargetFrameName,
101cdf0e10cSrcweir                        sal_Bool bMap );
102cdf0e10cSrcweir 
GetHRef() const103cdf0e10cSrcweir     const OUString& GetHRef() const { return sHRef; }
GetName() const104cdf0e10cSrcweir     const OUString& GetName() const { return sName; }
GetTargetFrameName() const105cdf0e10cSrcweir     const OUString& GetTargetFrameName() const { return sTargetFrameName; }
GetMap() const106cdf0e10cSrcweir     sal_Bool GetMap() const { return bMap; }
107cdf0e10cSrcweir };
108cdf0e10cSrcweir 
XMLTextFrameContextHyperlink_Impl(const OUString & rHRef,const OUString & rName,const OUString & rTargetFrameName,sal_Bool bM)109cdf0e10cSrcweir inline XMLTextFrameContextHyperlink_Impl::XMLTextFrameContextHyperlink_Impl(
110cdf0e10cSrcweir     const OUString& rHRef, const OUString& rName,
111cdf0e10cSrcweir     const OUString& rTargetFrameName, sal_Bool bM ) :
112cdf0e10cSrcweir     sHRef( rHRef ),
113cdf0e10cSrcweir     sName( rName ),
114cdf0e10cSrcweir     sTargetFrameName( rTargetFrameName ),
115cdf0e10cSrcweir     bMap( bM )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir // --> OD 2009-07-22 #i73249#
120cdf0e10cSrcweir class XMLTextFrameTitleOrDescContext_Impl : public SvXMLImportContext
121cdf0e10cSrcweir {
122cdf0e10cSrcweir     OUString&   mrTitleOrDesc;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir public:
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     TYPEINFO();
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     XMLTextFrameTitleOrDescContext_Impl( SvXMLImport& rImport,
129cdf0e10cSrcweir                                          sal_uInt16 nPrfx,
130cdf0e10cSrcweir                                          const ::rtl::OUString& rLName,
131cdf0e10cSrcweir                                          OUString& rTitleOrDesc );
132cdf0e10cSrcweir     virtual ~XMLTextFrameTitleOrDescContext_Impl();
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     virtual void Characters( const OUString& rText );
135cdf0e10cSrcweir };
136cdf0e10cSrcweir 
137cdf0e10cSrcweir TYPEINIT1( XMLTextFrameTitleOrDescContext_Impl, SvXMLImportContext );
138cdf0e10cSrcweir 
XMLTextFrameTitleOrDescContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,OUString & rTitleOrDesc)139cdf0e10cSrcweir XMLTextFrameTitleOrDescContext_Impl::XMLTextFrameTitleOrDescContext_Impl(
140cdf0e10cSrcweir         SvXMLImport& rImport,
141cdf0e10cSrcweir         sal_uInt16 nPrfx,
142cdf0e10cSrcweir         const OUString& rLName,
143cdf0e10cSrcweir         OUString& rTitleOrDesc )
144cdf0e10cSrcweir     : SvXMLImportContext( rImport, nPrfx, rLName )
145cdf0e10cSrcweir     , mrTitleOrDesc( rTitleOrDesc )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir }
148cdf0e10cSrcweir 
~XMLTextFrameTitleOrDescContext_Impl()149cdf0e10cSrcweir XMLTextFrameTitleOrDescContext_Impl::~XMLTextFrameTitleOrDescContext_Impl()
150cdf0e10cSrcweir {
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
Characters(const OUString & rText)153cdf0e10cSrcweir void XMLTextFrameTitleOrDescContext_Impl::Characters( const OUString& rText )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir     mrTitleOrDesc += rText;
156cdf0e10cSrcweir }
157cdf0e10cSrcweir // <--
158cdf0e10cSrcweir 
159cdf0e10cSrcweir // ------------------------------------------------------------------------
160cdf0e10cSrcweir 
161cdf0e10cSrcweir class XMLTextFrameParam_Impl : public SvXMLImportContext
162cdf0e10cSrcweir {
163cdf0e10cSrcweir public:
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     TYPEINFO();
166cdf0e10cSrcweir 
167cdf0e10cSrcweir     XMLTextFrameParam_Impl( SvXMLImport& rImport, sal_uInt16 nPrfx,
168cdf0e10cSrcweir                                   const ::rtl::OUString& rLName,
169cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
170cdf0e10cSrcweir                 ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
171cdf0e10cSrcweir             sal_uInt16 nType,
172cdf0e10cSrcweir             ParamMap &rParamMap);
173cdf0e10cSrcweir     virtual ~XMLTextFrameParam_Impl();
174cdf0e10cSrcweir };
175cdf0e10cSrcweir 
176cdf0e10cSrcweir TYPEINIT1( XMLTextFrameParam_Impl, SvXMLImportContext );
177cdf0e10cSrcweir 
~XMLTextFrameParam_Impl()178cdf0e10cSrcweir XMLTextFrameParam_Impl::~XMLTextFrameParam_Impl()
179cdf0e10cSrcweir {
180cdf0e10cSrcweir }
181cdf0e10cSrcweir 
XMLTextFrameParam_Impl(SvXMLImport & rImport,sal_uInt16 nPrfx,const::rtl::OUString & rLName,const::com::sun::star::uno::Reference<::com::sun::star::xml::sax::XAttributeList> & xAttrList,sal_uInt16,ParamMap & rParamMap)182cdf0e10cSrcweir XMLTextFrameParam_Impl::XMLTextFrameParam_Impl(
183cdf0e10cSrcweir         SvXMLImport& rImport, sal_uInt16 nPrfx,
184cdf0e10cSrcweir         const ::rtl::OUString& rLName,
185cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
186cdf0e10cSrcweir                 ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
187cdf0e10cSrcweir         sal_uInt16 /*nType*/,
188cdf0e10cSrcweir         ParamMap &rParamMap):
189cdf0e10cSrcweir     SvXMLImportContext( rImport, nPrfx, rLName )
190cdf0e10cSrcweir {
191cdf0e10cSrcweir     OUString sName, sValue;
192cdf0e10cSrcweir     sal_Bool bFoundValue = sal_False; // to allow empty values
193cdf0e10cSrcweir     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
194cdf0e10cSrcweir     for( sal_Int16 i=0; i < nAttrCount; i++ )
195cdf0e10cSrcweir     {
196cdf0e10cSrcweir         const OUString& rAttrName = xAttrList->getNameByIndex( i );
197cdf0e10cSrcweir         const OUString& rValue = xAttrList->getValueByIndex( i );
198cdf0e10cSrcweir 
199cdf0e10cSrcweir         OUString aLocalName;
200cdf0e10cSrcweir         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName );
201cdf0e10cSrcweir         if ( XML_NAMESPACE_DRAW == nPrefix )
202cdf0e10cSrcweir         {
203cdf0e10cSrcweir             if( IsXMLToken(aLocalName, XML_VALUE) )
204cdf0e10cSrcweir             {
205cdf0e10cSrcweir                 sValue = rValue;
206cdf0e10cSrcweir                 bFoundValue=sal_True;
207cdf0e10cSrcweir             }
208cdf0e10cSrcweir             else if( IsXMLToken(aLocalName, XML_NAME) )
209cdf0e10cSrcweir             {
210cdf0e10cSrcweir                 sName = rValue;
211cdf0e10cSrcweir             }
212cdf0e10cSrcweir         }
213cdf0e10cSrcweir     }
214cdf0e10cSrcweir     if (sName.getLength() && bFoundValue )
215cdf0e10cSrcweir         rParamMap[sName] = sValue;
216cdf0e10cSrcweir }
217cdf0e10cSrcweir class XMLTextFrameContourContext_Impl : public SvXMLImportContext
218cdf0e10cSrcweir {
219cdf0e10cSrcweir     Reference < XPropertySet > xPropSet;
220cdf0e10cSrcweir 
221cdf0e10cSrcweir public:
222cdf0e10cSrcweir 
223cdf0e10cSrcweir     TYPEINFO();
224cdf0e10cSrcweir 
225cdf0e10cSrcweir     XMLTextFrameContourContext_Impl( SvXMLImport& rImport, sal_uInt16 nPrfx,
226cdf0e10cSrcweir                                   const ::rtl::OUString& rLName,
227cdf0e10cSrcweir             const ::com::sun::star::uno::Reference<
228cdf0e10cSrcweir                 ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
229cdf0e10cSrcweir             const Reference < XPropertySet >& rPropSet,
230cdf0e10cSrcweir             sal_Bool bPath );
231cdf0e10cSrcweir     virtual ~XMLTextFrameContourContext_Impl();
232cdf0e10cSrcweir };
233cdf0e10cSrcweir 
234cdf0e10cSrcweir TYPEINIT1( XMLTextFrameContourContext_Impl, SvXMLImportContext );
235cdf0e10cSrcweir 
XMLTextFrameContourContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<XAttributeList> & xAttrList,const Reference<XPropertySet> & rPropSet,sal_Bool bPath)236cdf0e10cSrcweir XMLTextFrameContourContext_Impl::XMLTextFrameContourContext_Impl(
237cdf0e10cSrcweir         SvXMLImport& rImport,
238cdf0e10cSrcweir         sal_uInt16 nPrfx, const OUString& rLName,
239cdf0e10cSrcweir         const Reference< XAttributeList > & xAttrList,
240cdf0e10cSrcweir         const Reference < XPropertySet >& rPropSet,
241cdf0e10cSrcweir         sal_Bool bPath ) :
242cdf0e10cSrcweir     SvXMLImportContext( rImport, nPrfx, rLName ),
243cdf0e10cSrcweir     xPropSet( rPropSet )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir     OUString sD, sPoints, sViewBox;
246cdf0e10cSrcweir     sal_Bool bPixelWidth = sal_False, bPixelHeight = sal_False;
247cdf0e10cSrcweir     sal_Bool bAuto = sal_False;
248cdf0e10cSrcweir     sal_Int32 nWidth = 0;
249cdf0e10cSrcweir     sal_Int32 nHeight = 0;
250cdf0e10cSrcweir 
251cdf0e10cSrcweir     const SvXMLTokenMap& rTokenMap =
252cdf0e10cSrcweir         GetImport().GetTextImport()->GetTextContourAttrTokenMap();
253cdf0e10cSrcweir 
254cdf0e10cSrcweir     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
255cdf0e10cSrcweir     for( sal_Int16 i=0; i < nAttrCount; i++ )
256cdf0e10cSrcweir     {
257cdf0e10cSrcweir         const OUString& rAttrName = xAttrList->getNameByIndex( i );
258cdf0e10cSrcweir         const OUString& rValue = xAttrList->getValueByIndex( i );
259cdf0e10cSrcweir 
260cdf0e10cSrcweir         OUString aLocalName;
261cdf0e10cSrcweir         sal_uInt16 nPrefix =
262cdf0e10cSrcweir             GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
263cdf0e10cSrcweir                                                             &aLocalName );
264cdf0e10cSrcweir         switch( rTokenMap.Get( nPrefix, aLocalName ) )
265cdf0e10cSrcweir         {
266cdf0e10cSrcweir         case XML_TOK_TEXT_CONTOUR_VIEWBOX:
267cdf0e10cSrcweir             sViewBox = rValue;
268cdf0e10cSrcweir             break;
269cdf0e10cSrcweir         case XML_TOK_TEXT_CONTOUR_D:
270cdf0e10cSrcweir             if( bPath )
271cdf0e10cSrcweir                 sD = rValue;
272cdf0e10cSrcweir             break;
273cdf0e10cSrcweir         case XML_TOK_TEXT_CONTOUR_POINTS:
274cdf0e10cSrcweir             if( !bPath )
275cdf0e10cSrcweir                 sPoints = rValue;
276cdf0e10cSrcweir             break;
277cdf0e10cSrcweir         case XML_TOK_TEXT_CONTOUR_WIDTH:
278cdf0e10cSrcweir             if( GetImport().GetMM100UnitConverter().convertMeasurePx( nWidth,
279cdf0e10cSrcweir                                                                       rValue) )
280cdf0e10cSrcweir                 bPixelWidth = sal_True;
281cdf0e10cSrcweir             else
282cdf0e10cSrcweir                 GetImport().GetMM100UnitConverter().convertMeasure( nWidth,
283cdf0e10cSrcweir                                                                 rValue);
284cdf0e10cSrcweir             break;
285cdf0e10cSrcweir         case XML_TOK_TEXT_CONTOUR_HEIGHT:
286cdf0e10cSrcweir             if( GetImport().GetMM100UnitConverter().convertMeasurePx( nHeight,
287cdf0e10cSrcweir                                                                 rValue) )
288cdf0e10cSrcweir                 bPixelHeight = sal_True;
289cdf0e10cSrcweir             else
290cdf0e10cSrcweir                 GetImport().GetMM100UnitConverter().convertMeasure( nHeight,
291cdf0e10cSrcweir                                                                     rValue);
292cdf0e10cSrcweir             break;
293cdf0e10cSrcweir         case XML_TOK_TEXT_CONTOUR_AUTO:
294cdf0e10cSrcweir             bAuto = IsXMLToken(rValue, XML_TRUE);
295cdf0e10cSrcweir             break;
296cdf0e10cSrcweir         }
297cdf0e10cSrcweir     }
298cdf0e10cSrcweir 
2991f882ec4SArmin Le Grand     OUString sContourPolyPolygon(RTL_CONSTASCII_USTRINGPARAM("ContourPolyPolygon"));
3001f882ec4SArmin Le Grand     Reference < XPropertySetInfo > xPropSetInfo = rPropSet->getPropertySetInfo();
3011f882ec4SArmin Le Grand 
3021f882ec4SArmin Le Grand     if(xPropSetInfo->hasPropertyByName(sContourPolyPolygon) && nWidth > 0 && nHeight > 0 && bPixelWidth == bPixelHeight && (bPath ? sD : sPoints).getLength())
303cdf0e10cSrcweir     {
3041f882ec4SArmin Le Grand         const SdXMLImExViewBox aViewBox( sViewBox, GetImport().GetMM100UnitConverter());
3051f882ec4SArmin Le Grand         basegfx::B2DPolyPolygon aPolyPolygon;
306cdf0e10cSrcweir         Any aAny;
3071f882ec4SArmin Le Grand 
308cdf0e10cSrcweir         if( bPath )
309cdf0e10cSrcweir         {
3101f882ec4SArmin Le Grand             basegfx::tools::importFromSvgD(aPolyPolygon, sD, true, 0);
311cdf0e10cSrcweir         }
312cdf0e10cSrcweir         else
313cdf0e10cSrcweir         {
3141f882ec4SArmin Le Grand             basegfx::B2DPolygon aPolygon;
3151f882ec4SArmin Le Grand 
3161f882ec4SArmin Le Grand             if(basegfx::tools::importFromSvgPoints(aPolygon, sPoints))
3171f882ec4SArmin Le Grand             {
3181f882ec4SArmin Le Grand                 aPolyPolygon = basegfx::B2DPolyPolygon(aPolygon);
3191f882ec4SArmin Le Grand             }
320cdf0e10cSrcweir         }
321cdf0e10cSrcweir 
3221f882ec4SArmin Le Grand         if(aPolyPolygon.count())
3231f882ec4SArmin Le Grand         {
3241f882ec4SArmin Le Grand             const basegfx::B2DRange aSourceRange(
3251f882ec4SArmin Le Grand                 aViewBox.GetX(), aViewBox.GetY(),
3261f882ec4SArmin Le Grand                 aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
3271f882ec4SArmin Le Grand             const basegfx::B2DRange aTargetRange(
3281f882ec4SArmin Le Grand                 0.0, 0.0,
3291f882ec4SArmin Le Grand                 nWidth, nHeight);
3301f882ec4SArmin Le Grand 
3311f882ec4SArmin Le Grand             if(!aSourceRange.equal(aTargetRange))
3321f882ec4SArmin Le Grand             {
3331f882ec4SArmin Le Grand                 aPolyPolygon.transform(
3341f882ec4SArmin Le Grand                     basegfx::tools::createSourceRangeTargetRangeTransform(
3351f882ec4SArmin Le Grand                         aSourceRange,
3361f882ec4SArmin Le Grand                         aTargetRange));
3371f882ec4SArmin Le Grand             }
3381f882ec4SArmin Le Grand 
3391f882ec4SArmin Le Grand             com::sun::star::drawing::PointSequenceSequence aPointSequenceSequence;
3401f882ec4SArmin Le Grand             basegfx::tools::B2DPolyPolygonToUnoPointSequenceSequence(aPolyPolygon, aPointSequenceSequence);
3411f882ec4SArmin Le Grand             aAny <<= aPointSequenceSequence;
342cdf0e10cSrcweir             xPropSet->setPropertyValue( sContourPolyPolygon, aAny );
3431f882ec4SArmin Le Grand         }
3441f882ec4SArmin Le Grand 
3451f882ec4SArmin Le Grand         const OUString sIsPixelContour(RTL_CONSTASCII_USTRINGPARAM("IsPixelContour"));
346cdf0e10cSrcweir 
347cdf0e10cSrcweir         if( xPropSetInfo->hasPropertyByName( sIsPixelContour ) )
348cdf0e10cSrcweir         {
349cdf0e10cSrcweir             aAny.setValue( &bPixelWidth, ::getBooleanCppuType() );
350cdf0e10cSrcweir             xPropSet->setPropertyValue( sIsPixelContour, aAny );
351cdf0e10cSrcweir         }
352cdf0e10cSrcweir 
3531f882ec4SArmin Le Grand         const OUString sIsAutomaticContour(RTL_CONSTASCII_USTRINGPARAM("IsAutomaticContour") );
3541f882ec4SArmin Le Grand 
355cdf0e10cSrcweir         if( xPropSetInfo->hasPropertyByName( sIsAutomaticContour ) )
356cdf0e10cSrcweir         {
357cdf0e10cSrcweir             aAny.setValue( &bAuto, ::getBooleanCppuType() );
358cdf0e10cSrcweir             xPropSet->setPropertyValue( sIsAutomaticContour, aAny );
359cdf0e10cSrcweir         }
360cdf0e10cSrcweir     }
361cdf0e10cSrcweir }
362cdf0e10cSrcweir 
~XMLTextFrameContourContext_Impl()363cdf0e10cSrcweir XMLTextFrameContourContext_Impl::~XMLTextFrameContourContext_Impl()
364cdf0e10cSrcweir {
365cdf0e10cSrcweir }
366cdf0e10cSrcweir 
367cdf0e10cSrcweir // ------------------------------------------------------------------------
368cdf0e10cSrcweir 
369cdf0e10cSrcweir class XMLTextFrameContext_Impl : public SvXMLImportContext
370cdf0e10cSrcweir {
371cdf0e10cSrcweir     ::com::sun::star::uno::Reference <
372cdf0e10cSrcweir         ::com::sun::star::text::XTextCursor > xOldTextCursor;
373cdf0e10cSrcweir     ::com::sun::star::uno::Reference <
374cdf0e10cSrcweir         ::com::sun::star::beans::XPropertySet > xPropSet;
375cdf0e10cSrcweir     ::com::sun::star::uno::Reference <
376cdf0e10cSrcweir         ::com::sun::star::io::XOutputStream > xBase64Stream;
377cdf0e10cSrcweir 
378cdf0e10cSrcweir     /// old list item and block (#89891#)
379cdf0e10cSrcweir     bool mbListContextPushed;
380cdf0e10cSrcweir 
381cdf0e10cSrcweir     const ::rtl::OUString sWidth;
382cdf0e10cSrcweir     const ::rtl::OUString sWidthType;
383cdf0e10cSrcweir     const ::rtl::OUString sRelativeWidth;
384cdf0e10cSrcweir     const ::rtl::OUString sHeight;
385cdf0e10cSrcweir     const ::rtl::OUString sRelativeHeight;
386cdf0e10cSrcweir     const ::rtl::OUString sSizeType;
387cdf0e10cSrcweir     const ::rtl::OUString sIsSyncWidthToHeight;
388cdf0e10cSrcweir     const ::rtl::OUString sIsSyncHeightToWidth;
389cdf0e10cSrcweir     const ::rtl::OUString sHoriOrient;
390cdf0e10cSrcweir     const ::rtl::OUString sHoriOrientPosition;
391cdf0e10cSrcweir     const ::rtl::OUString sVertOrient;
392cdf0e10cSrcweir     const ::rtl::OUString sVertOrientPosition;
393cdf0e10cSrcweir     const ::rtl::OUString sChainNextName;
394cdf0e10cSrcweir     const ::rtl::OUString sAnchorType;
395cdf0e10cSrcweir     const ::rtl::OUString sAnchorPageNo;
396cdf0e10cSrcweir     const ::rtl::OUString sGraphicURL;
397cdf0e10cSrcweir     const ::rtl::OUString sGraphicFilter;
398cdf0e10cSrcweir     // --> OD 2009-07-22 #i73249#
399cdf0e10cSrcweir //    const ::rtl::OUString sAlternativeText;
400cdf0e10cSrcweir     const ::rtl::OUString sTitle;
401cdf0e10cSrcweir     const ::rtl::OUString sDescription;
402cdf0e10cSrcweir     // <--
403cdf0e10cSrcweir     const ::rtl::OUString sFrameStyleName;
404cdf0e10cSrcweir     const ::rtl::OUString sGraphicRotation;
405cdf0e10cSrcweir     const ::rtl::OUString sTextBoxServiceName;
406cdf0e10cSrcweir     const ::rtl::OUString sGraphicServiceName;
407cdf0e10cSrcweir 
408cdf0e10cSrcweir     ::rtl::OUString sName;
409cdf0e10cSrcweir     ::rtl::OUString sStyleName;
410cdf0e10cSrcweir     ::rtl::OUString sNextName;
411cdf0e10cSrcweir     ::rtl::OUString sHRef;
412cdf0e10cSrcweir     ::rtl::OUString sFilterName;
413cdf0e10cSrcweir     ::rtl::OUString sCode;
414cdf0e10cSrcweir     ::rtl::OUString sObject;
415cdf0e10cSrcweir     ::rtl::OUString sArchive;
416cdf0e10cSrcweir     ::rtl::OUString sMimeType;
417cdf0e10cSrcweir     ::rtl::OUString sFrameName;
418cdf0e10cSrcweir     ::rtl::OUString sAppletName;
419cdf0e10cSrcweir     ::rtl::OUString sFilterService;
420cdf0e10cSrcweir     ::rtl::OUString sBase64CharsLeft;
421cdf0e10cSrcweir     ::rtl::OUString sTblName;
422cdf0e10cSrcweir 
423cdf0e10cSrcweir     ParamMap aParamMap;
424cdf0e10cSrcweir 
425cdf0e10cSrcweir     sal_Int32   nX;
426cdf0e10cSrcweir     sal_Int32   nY;
427cdf0e10cSrcweir     sal_Int32   nWidth;
428cdf0e10cSrcweir     sal_Int32   nHeight;
429cdf0e10cSrcweir     sal_Int32   nZIndex;
430cdf0e10cSrcweir     sal_Int16   nPage;
431cdf0e10cSrcweir     sal_Int16   nRotation;
432cdf0e10cSrcweir     sal_Int16   nRelWidth;
433cdf0e10cSrcweir     sal_Int16   nRelHeight;
434cdf0e10cSrcweir 
435cdf0e10cSrcweir     sal_uInt16 nType;
436cdf0e10cSrcweir     ::com::sun::star::text::TextContentAnchorType   eAnchorType;
437cdf0e10cSrcweir 
438cdf0e10cSrcweir     sal_Bool    bMayScript : 1;
439cdf0e10cSrcweir     sal_Bool    bMinWidth : 1;
440cdf0e10cSrcweir     sal_Bool    bMinHeight : 1;
441cdf0e10cSrcweir     sal_Bool    bSyncWidth : 1;
442cdf0e10cSrcweir     sal_Bool    bSyncHeight : 1;
443cdf0e10cSrcweir     sal_Bool    bCreateFailed : 1;
444cdf0e10cSrcweir     sal_Bool    bOwnBase64Stream : 1;
445011bafbfSArmin Le Grand     bool        mbSetNameForFrame : 1; // #123261# remember if to set the NameForFrame
446cdf0e10cSrcweir 
447cdf0e10cSrcweir     void Create( sal_Bool bHRefOrBase64 );
448cdf0e10cSrcweir 
449cdf0e10cSrcweir public:
450cdf0e10cSrcweir 
451cdf0e10cSrcweir     TYPEINFO();
452cdf0e10cSrcweir 
453cdf0e10cSrcweir     sal_Bool CreateIfNotThere();
GetHRef() const454ddde725dSArmin Le Grand     const OUString& GetHRef() const { return sHRef; }
455cdf0e10cSrcweir 
456cdf0e10cSrcweir     XMLTextFrameContext_Impl( SvXMLImport& rImport,
457cdf0e10cSrcweir         sal_uInt16 nPrfx,
458cdf0e10cSrcweir         const ::rtl::OUString& rLName,
459cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
460cdf0e10cSrcweir         ::com::sun::star::xml::sax::XAttributeList > & rAttrList,
461cdf0e10cSrcweir         ::com::sun::star::text::TextContentAnchorType eAnchorType,
462cdf0e10cSrcweir         sal_uInt16 nType,
463011bafbfSArmin Le Grand         const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & rFrameAttrList,
464011bafbfSArmin Le Grand         bool bSetNameForFrame); // #123261# control if to set the NameForFrame
465cdf0e10cSrcweir     virtual ~XMLTextFrameContext_Impl();
466cdf0e10cSrcweir 
467cdf0e10cSrcweir     virtual void EndElement();
468cdf0e10cSrcweir 
469cdf0e10cSrcweir     virtual void Characters( const ::rtl::OUString& rChars );
470cdf0e10cSrcweir 
471cdf0e10cSrcweir     SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
472cdf0e10cSrcweir                 const ::rtl::OUString& rLocalName,
473cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference<
474cdf0e10cSrcweir                     ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
475cdf0e10cSrcweir 
476cdf0e10cSrcweir     void SetHyperlink( const ::rtl::OUString& rHRef,
477cdf0e10cSrcweir                        const ::rtl::OUString& rName,
478cdf0e10cSrcweir                        const ::rtl::OUString& rTargetFrameName,
479cdf0e10cSrcweir                        sal_Bool bMap );
480cdf0e10cSrcweir     // --> OD 2009-07-22 #i73249#
481cdf0e10cSrcweir     void SetTitle( const ::rtl::OUString& rTitle );
482cdf0e10cSrcweir     // <--
483cdf0e10cSrcweir     void SetDesc( const ::rtl::OUString& rDesc );
484cdf0e10cSrcweir 
GetAnchorType() const485cdf0e10cSrcweir     ::com::sun::star::text::TextContentAnchorType GetAnchorType() const { return eAnchorType; }
486cdf0e10cSrcweir 
487cdf0e10cSrcweir     const ::com::sun::star::uno::Reference <
GetPropSet() const488ddde725dSArmin Le Grand         ::com::sun::star::beans::XPropertySet >& GetPropSet() const { return xPropSet; }
489011bafbfSArmin Le Grand 
490011bafbfSArmin Le Grand     // #123261# helper to set the NameForFrame
491011bafbfSArmin Le Grand     void SetNameForFrameFromPropSet();
492cdf0e10cSrcweir };
493cdf0e10cSrcweir 
494cdf0e10cSrcweir TYPEINIT1( XMLTextFrameContext_Impl, SvXMLImportContext );
495cdf0e10cSrcweir 
SetNameForFrameFromPropSet()496011bafbfSArmin Le Grand void XMLTextFrameContext_Impl::SetNameForFrameFromPropSet()
497011bafbfSArmin Le Grand {
498011bafbfSArmin Le Grand     // set name
499011bafbfSArmin Le Grand     UniReference < XMLTextImportHelper > xTextImportHelper = GetImport().GetTextImport();
500011bafbfSArmin Le Grand     Reference < XNamed > xNamed( xPropSet, UNO_QUERY );
501011bafbfSArmin Le Grand 
502011bafbfSArmin Le Grand     if( xNamed.is() && xTextImportHelper.is() )
503011bafbfSArmin Le Grand     {
504011bafbfSArmin Le Grand         OUString sOrigName( xNamed->getName() );
505011bafbfSArmin Le Grand         if( !sOrigName.getLength() ||
506011bafbfSArmin Le Grand             (sName.getLength() && sOrigName != sName) )
507011bafbfSArmin Le Grand         {
508011bafbfSArmin Le Grand             OUString sOldName( sName );
509011bafbfSArmin Le Grand             sal_Int32 i = 0;
510011bafbfSArmin Le Grand             while( xTextImportHelper->HasFrameByName( sName ) )
511011bafbfSArmin Le Grand             {
512011bafbfSArmin Le Grand                 sName = sOldName;
513011bafbfSArmin Le Grand                 sName += OUString::valueOf( ++i );
514011bafbfSArmin Le Grand             }
515011bafbfSArmin Le Grand             xNamed->setName( sName );
516011bafbfSArmin Le Grand             if( sName != sOldName )
517011bafbfSArmin Le Grand                 xTextImportHelper->GetRenameMap().Add( XML_TEXT_RENAME_TYPE_FRAME,
518011bafbfSArmin Le Grand                                              sOldName, sName );
519011bafbfSArmin Le Grand         }
520011bafbfSArmin Le Grand     }
521011bafbfSArmin Le Grand }
522011bafbfSArmin Le Grand 
Create(sal_Bool)523cdf0e10cSrcweir void XMLTextFrameContext_Impl::Create( sal_Bool /*bHRefOrBase64*/ )
524cdf0e10cSrcweir {
525cdf0e10cSrcweir     UniReference < XMLTextImportHelper > xTextImportHelper =
526cdf0e10cSrcweir         GetImport().GetTextImport();
527cdf0e10cSrcweir 
528cdf0e10cSrcweir     switch ( nType)
529cdf0e10cSrcweir     {
530cdf0e10cSrcweir         case XML_TEXT_FRAME_OBJECT:
531cdf0e10cSrcweir         case XML_TEXT_FRAME_OBJECT_OLE:
532cdf0e10cSrcweir             if( xBase64Stream.is() )
533cdf0e10cSrcweir             {
534cdf0e10cSrcweir                 OUString sURL( GetImport().ResolveEmbeddedObjectURLFromBase64() );
535cdf0e10cSrcweir                 if( sURL.getLength() )
536cdf0e10cSrcweir                     xPropSet = GetImport().GetTextImport()
537cdf0e10cSrcweir                             ->createAndInsertOLEObject( GetImport(), sURL,
538cdf0e10cSrcweir                                                         sStyleName,
539cdf0e10cSrcweir                                                         sTblName,
540cdf0e10cSrcweir                                                         nWidth, nHeight );
541cdf0e10cSrcweir             }
542cdf0e10cSrcweir             else if( sHRef.getLength() )
543cdf0e10cSrcweir             {
544cdf0e10cSrcweir                 OUString sURL( GetImport().ResolveEmbeddedObjectURL( sHRef,
545cdf0e10cSrcweir                                                                 OUString() ) );
546cdf0e10cSrcweir 
547cdf0e10cSrcweir                 if( GetImport().IsPackageURL( sHRef ) )
548cdf0e10cSrcweir                 {
549cdf0e10cSrcweir                     xPropSet = GetImport().GetTextImport()
550cdf0e10cSrcweir                             ->createAndInsertOLEObject( GetImport(), sURL,
551cdf0e10cSrcweir                                                         sStyleName,
552cdf0e10cSrcweir                                                         sTblName,
553cdf0e10cSrcweir                                                         nWidth, nHeight );
554cdf0e10cSrcweir                 }
555cdf0e10cSrcweir                 else
556cdf0e10cSrcweir                 {
557cdf0e10cSrcweir                     // it should be an own OOo link that has no storage persistance
558cdf0e10cSrcweir                     xPropSet = GetImport().GetTextImport()
559cdf0e10cSrcweir                             ->createAndInsertOOoLink( GetImport(),
560cdf0e10cSrcweir                                                         sURL,
561cdf0e10cSrcweir                                                         sStyleName,
562cdf0e10cSrcweir                                                         sTblName,
563cdf0e10cSrcweir                                                         nWidth, nHeight );
564cdf0e10cSrcweir                 }
565cdf0e10cSrcweir             }
566cdf0e10cSrcweir             else
567cdf0e10cSrcweir             {
568cdf0e10cSrcweir                 OUString sURL( RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.ServiceName:") );
569cdf0e10cSrcweir                 sURL += sFilterService;
570cdf0e10cSrcweir                 xPropSet = GetImport().GetTextImport()
571cdf0e10cSrcweir                             ->createAndInsertOLEObject( GetImport(), sURL,
572cdf0e10cSrcweir                                                         sStyleName,
573cdf0e10cSrcweir                                                         sTblName,
574cdf0e10cSrcweir                                                         nWidth, nHeight );
575cdf0e10cSrcweir 
576cdf0e10cSrcweir             }
577cdf0e10cSrcweir             break;
578cdf0e10cSrcweir         case XML_TEXT_FRAME_APPLET:
579cdf0e10cSrcweir         {
580cdf0e10cSrcweir             xPropSet = GetImport().GetTextImport()
581cdf0e10cSrcweir                             ->createAndInsertApplet( sAppletName, sCode,
582cdf0e10cSrcweir                                                      bMayScript, sHRef,
583cdf0e10cSrcweir                                                      nWidth, nHeight);
584cdf0e10cSrcweir             break;
585cdf0e10cSrcweir         }
586cdf0e10cSrcweir         case XML_TEXT_FRAME_PLUGIN:
587cdf0e10cSrcweir         {
588cdf0e10cSrcweir             if(sHRef.getLength())
589cdf0e10cSrcweir                 GetImport().GetAbsoluteReference(sHRef);
590cdf0e10cSrcweir             xPropSet = GetImport().GetTextImport()
591cdf0e10cSrcweir                             ->createAndInsertPlugin( sMimeType, sHRef,
592cdf0e10cSrcweir                                                      nWidth, nHeight);
593cdf0e10cSrcweir 
594cdf0e10cSrcweir             break;
595cdf0e10cSrcweir         }
596cdf0e10cSrcweir         case XML_TEXT_FRAME_FLOATING_FRAME:
597cdf0e10cSrcweir         {
598cdf0e10cSrcweir             xPropSet = GetImport().GetTextImport()
599cdf0e10cSrcweir                             ->createAndInsertFloatingFrame( sFrameName, sHRef,
600cdf0e10cSrcweir                                                             sStyleName,
601cdf0e10cSrcweir                                                             nWidth, nHeight);
602cdf0e10cSrcweir             break;
603cdf0e10cSrcweir         }
604cdf0e10cSrcweir         default:
605cdf0e10cSrcweir         {
606cdf0e10cSrcweir             Reference<XMultiServiceFactory> xFactory( GetImport().GetModel(),
607cdf0e10cSrcweir                                                       UNO_QUERY );
608cdf0e10cSrcweir             if( xFactory.is() )
609cdf0e10cSrcweir             {
610cdf0e10cSrcweir                 OUString sServiceName;
611cdf0e10cSrcweir                 switch( nType )
612cdf0e10cSrcweir                 {
613cdf0e10cSrcweir                     case XML_TEXT_FRAME_TEXTBOX: sServiceName = sTextBoxServiceName; break;
614cdf0e10cSrcweir                     case XML_TEXT_FRAME_GRAPHIC: sServiceName = sGraphicServiceName; break;
615cdf0e10cSrcweir                 }
616cdf0e10cSrcweir                 Reference<XInterface> xIfc = xFactory->createInstance( sServiceName );
617cdf0e10cSrcweir                 DBG_ASSERT( xIfc.is(), "couldn't create frame" );
618cdf0e10cSrcweir                 if( xIfc.is() )
619cdf0e10cSrcweir                     xPropSet = Reference < XPropertySet >( xIfc, UNO_QUERY );
620cdf0e10cSrcweir             }
621cdf0e10cSrcweir         }
622cdf0e10cSrcweir     }
623cdf0e10cSrcweir 
624cdf0e10cSrcweir     if( !xPropSet.is() )
625cdf0e10cSrcweir     {
626cdf0e10cSrcweir         bCreateFailed = sal_True;
627cdf0e10cSrcweir         return;
628cdf0e10cSrcweir     }
629cdf0e10cSrcweir 
630cdf0e10cSrcweir     Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
631cdf0e10cSrcweir 
632011bafbfSArmin Le Grand     // #123261# set name, but only if wanted, e.g. for MultiImageSupport, it will be set after
633011bafbfSArmin Le Grand     // it is decided which image will be used. This is done e.g. to avoid double stuff and effects
634011bafbfSArmin Le Grand     // for the target to avoid double names
635011bafbfSArmin Le Grand     if(mbSetNameForFrame)
636cdf0e10cSrcweir     {
637011bafbfSArmin Le Grand         SetNameForFrameFromPropSet();
638cdf0e10cSrcweir     }
639cdf0e10cSrcweir 
640cdf0e10cSrcweir     // frame style
641cdf0e10cSrcweir     XMLPropStyleContext *pStyle = 0;
642cdf0e10cSrcweir     if( sStyleName.getLength() )
643cdf0e10cSrcweir     {
644cdf0e10cSrcweir         pStyle = xTextImportHelper->FindAutoFrameStyle( sStyleName );
645cdf0e10cSrcweir         if( pStyle )
646cdf0e10cSrcweir             sStyleName = pStyle->GetParentName();
647cdf0e10cSrcweir     }
648cdf0e10cSrcweir 
649cdf0e10cSrcweir     Any aAny;
650cdf0e10cSrcweir     if( sStyleName.getLength() )
651cdf0e10cSrcweir     {
652cdf0e10cSrcweir         OUString sDisplayStyleName( GetImport().GetStyleDisplayName(
653cdf0e10cSrcweir                             XML_STYLE_FAMILY_SD_GRAPHICS_ID, sStyleName ) );
654cdf0e10cSrcweir         const Reference < XNameContainer > & rStyles =
655cdf0e10cSrcweir             xTextImportHelper->GetFrameStyles();
656cdf0e10cSrcweir         if( rStyles.is() &&
657cdf0e10cSrcweir             rStyles->hasByName( sDisplayStyleName ) )
658cdf0e10cSrcweir         {
659cdf0e10cSrcweir             aAny <<= sDisplayStyleName;
660cdf0e10cSrcweir             xPropSet->setPropertyValue( sFrameStyleName, aAny );
661cdf0e10cSrcweir         }
662cdf0e10cSrcweir     }
663cdf0e10cSrcweir 
664cdf0e10cSrcweir     // anchor type (must be set before any other properties, because
665cdf0e10cSrcweir     // otherwise some orientations cannot be set or will be changed
666cdf0e10cSrcweir     // afterwards)
667cdf0e10cSrcweir     aAny <<= eAnchorType;
668cdf0e10cSrcweir     xPropSet->setPropertyValue( sAnchorType, aAny );
669cdf0e10cSrcweir 
670cdf0e10cSrcweir     // hard properties
671cdf0e10cSrcweir     if( pStyle )
672cdf0e10cSrcweir         pStyle->FillPropertySet( xPropSet );
673cdf0e10cSrcweir 
674cdf0e10cSrcweir 
675cdf0e10cSrcweir     // x and y
676cdf0e10cSrcweir     sal_Int16 nHoriOrient =  HoriOrientation::NONE;
677cdf0e10cSrcweir     aAny = xPropSet->getPropertyValue( sHoriOrient );
678cdf0e10cSrcweir     aAny >>= nHoriOrient;
679cdf0e10cSrcweir     if( HoriOrientation::NONE == nHoriOrient )
680cdf0e10cSrcweir     {
681cdf0e10cSrcweir         aAny <<= nX;
682cdf0e10cSrcweir         xPropSet->setPropertyValue( sHoriOrientPosition, aAny );
683cdf0e10cSrcweir     }
684cdf0e10cSrcweir 
685cdf0e10cSrcweir     sal_Int16 nVertOrient =  VertOrientation::NONE;
686cdf0e10cSrcweir     aAny = xPropSet->getPropertyValue( sVertOrient );
687cdf0e10cSrcweir     aAny >>= nVertOrient;
688cdf0e10cSrcweir     if( VertOrientation::NONE == nVertOrient )
689cdf0e10cSrcweir     {
690cdf0e10cSrcweir         aAny <<= nY;
691cdf0e10cSrcweir         xPropSet->setPropertyValue( sVertOrientPosition, aAny );
692cdf0e10cSrcweir     }
693cdf0e10cSrcweir 
694cdf0e10cSrcweir     // width
695cdf0e10cSrcweir     if( nWidth > 0 )
696cdf0e10cSrcweir     {
697cdf0e10cSrcweir         aAny <<= nWidth;
698cdf0e10cSrcweir         xPropSet->setPropertyValue( sWidth, aAny );
699cdf0e10cSrcweir     }
700cdf0e10cSrcweir     if( nRelWidth > 0 || nWidth > 0 )
701cdf0e10cSrcweir     {
702cdf0e10cSrcweir         aAny <<= nRelWidth;
703cdf0e10cSrcweir         xPropSet->setPropertyValue( sRelativeWidth, aAny );
704cdf0e10cSrcweir     }
705cdf0e10cSrcweir     if( bSyncWidth || nWidth > 0 )
706cdf0e10cSrcweir     {
707cdf0e10cSrcweir         sal_Bool bTmp = bSyncWidth;
708cdf0e10cSrcweir         aAny.setValue( &bTmp, ::getBooleanCppuType() );
709cdf0e10cSrcweir         xPropSet->setPropertyValue( sIsSyncWidthToHeight, aAny );
710cdf0e10cSrcweir     }
711cdf0e10cSrcweir     if( xPropSetInfo->hasPropertyByName( sWidthType ) &&
712cdf0e10cSrcweir         (bMinWidth || nWidth > 0 || nRelWidth > 0 ) )
713cdf0e10cSrcweir     {
714cdf0e10cSrcweir         sal_Int16 nSizeType =
715cdf0e10cSrcweir             (bMinWidth && XML_TEXT_FRAME_TEXTBOX == nType) ? SizeType::MIN
716cdf0e10cSrcweir                                                            : SizeType::FIX;
717cdf0e10cSrcweir         aAny <<= nSizeType;
718cdf0e10cSrcweir         xPropSet->setPropertyValue( sWidthType, aAny );
719cdf0e10cSrcweir     }
720cdf0e10cSrcweir 
721cdf0e10cSrcweir     if( nHeight > 0 )
722cdf0e10cSrcweir     {
723cdf0e10cSrcweir         aAny <<= nHeight;
724cdf0e10cSrcweir         xPropSet->setPropertyValue( sHeight, aAny );
725cdf0e10cSrcweir     }
726cdf0e10cSrcweir     if( nRelHeight > 0 || nHeight > 0 )
727cdf0e10cSrcweir     {
728cdf0e10cSrcweir         aAny <<= nRelHeight;
729cdf0e10cSrcweir         xPropSet->setPropertyValue( sRelativeHeight, aAny );
730cdf0e10cSrcweir     }
731cdf0e10cSrcweir     if( bSyncHeight || nHeight > 0 )
732cdf0e10cSrcweir     {
733cdf0e10cSrcweir         sal_Bool bTmp = bSyncHeight;
734cdf0e10cSrcweir         aAny.setValue( &bTmp, ::getBooleanCppuType() );
735cdf0e10cSrcweir         xPropSet->setPropertyValue( sIsSyncHeightToWidth, aAny );
736cdf0e10cSrcweir     }
737cdf0e10cSrcweir     if( xPropSetInfo->hasPropertyByName( sSizeType ) &&
738cdf0e10cSrcweir         (bMinHeight || nHeight > 0 || nRelHeight > 0 ) )
739cdf0e10cSrcweir     {
740cdf0e10cSrcweir         sal_Int16 nSizeType =
741cdf0e10cSrcweir             (bMinHeight && XML_TEXT_FRAME_TEXTBOX == nType) ? SizeType::MIN
742cdf0e10cSrcweir                                                             : SizeType::FIX;
743cdf0e10cSrcweir         aAny <<= nSizeType;
744cdf0e10cSrcweir         xPropSet->setPropertyValue( sSizeType, aAny );
745cdf0e10cSrcweir     }
746cdf0e10cSrcweir 
747cdf0e10cSrcweir     if( XML_TEXT_FRAME_GRAPHIC == nType )
748cdf0e10cSrcweir     {
749cdf0e10cSrcweir         // URL
750cdf0e10cSrcweir         OSL_ENSURE( sHRef.getLength() > 0 || xBase64Stream.is(),
751cdf0e10cSrcweir                     "neither URL nor base64 image data given" );
752cdf0e10cSrcweir         UniReference < XMLTextImportHelper > xTxtImport =
753cdf0e10cSrcweir             GetImport().GetTextImport();
754cdf0e10cSrcweir         if( sHRef.getLength() )
755cdf0e10cSrcweir         {
756cdf0e10cSrcweir             sal_Bool bForceLoad = xTxtImport->IsInsertMode() ||
757cdf0e10cSrcweir                                   xTxtImport->IsBlockMode() ||
758cdf0e10cSrcweir                                   xTxtImport->IsStylesOnlyMode() ||
759cdf0e10cSrcweir                                   xTxtImport->IsOrganizerMode();
760cdf0e10cSrcweir             sHRef = GetImport().ResolveGraphicObjectURL( sHRef, !bForceLoad );
761cdf0e10cSrcweir         }
762cdf0e10cSrcweir         else if( xBase64Stream.is() )
763cdf0e10cSrcweir         {
764cdf0e10cSrcweir             sHRef = GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream );
765cdf0e10cSrcweir             xBase64Stream = 0;
766cdf0e10cSrcweir         }
767cdf0e10cSrcweir         aAny <<= sHRef;
768cdf0e10cSrcweir         xPropSet->setPropertyValue( sGraphicURL, aAny );
769cdf0e10cSrcweir 
770cdf0e10cSrcweir         // filter name
771cdf0e10cSrcweir         aAny <<=sFilterName;
772cdf0e10cSrcweir         xPropSet->setPropertyValue( sGraphicFilter, aAny );
773cdf0e10cSrcweir 
774cdf0e10cSrcweir         // rotation
775cdf0e10cSrcweir         aAny <<= nRotation;
776cdf0e10cSrcweir         xPropSet->setPropertyValue( sGraphicRotation, aAny );
777cdf0e10cSrcweir     }
778cdf0e10cSrcweir 
779cdf0e10cSrcweir     // page number (must be set after the frame is inserted, because it
780cdf0e10cSrcweir     // will be overwritten then inserting the frame.
781cdf0e10cSrcweir     if( TextContentAnchorType_AT_PAGE == eAnchorType && nPage > 0 )
782cdf0e10cSrcweir     {
783cdf0e10cSrcweir         aAny <<= nPage;
784cdf0e10cSrcweir         xPropSet->setPropertyValue( sAnchorPageNo, aAny );
785cdf0e10cSrcweir     }
786cdf0e10cSrcweir 
787cdf0e10cSrcweir     if( XML_TEXT_FRAME_OBJECT != nType  &&
788cdf0e10cSrcweir         XML_TEXT_FRAME_OBJECT_OLE != nType  &&
789cdf0e10cSrcweir         XML_TEXT_FRAME_APPLET != nType &&
790cdf0e10cSrcweir         XML_TEXT_FRAME_PLUGIN!= nType &&
791cdf0e10cSrcweir         XML_TEXT_FRAME_FLOATING_FRAME != nType)
792cdf0e10cSrcweir     {
793cdf0e10cSrcweir         Reference < XTextContent > xTxtCntnt( xPropSet, UNO_QUERY );
794cdf0e10cSrcweir         xTextImportHelper->InsertTextContent( xTxtCntnt );
795cdf0e10cSrcweir     }
796cdf0e10cSrcweir 
797cdf0e10cSrcweir     // #107848#
798cdf0e10cSrcweir     // Make adding the shepe to Z-Ordering dependent from if we are
799cdf0e10cSrcweir     // inside a inside_deleted_section (redlining). That is necessary
800cdf0e10cSrcweir     // since the shape will be removed again later. It would lead to
801cdf0e10cSrcweir     // errors if it would stay inside the Z-Ordering. Thus, the
802cdf0e10cSrcweir     // easiest way to solve that conflict is to not add it here.
803cdf0e10cSrcweir     if(!GetImport().HasTextImport()
804cdf0e10cSrcweir         || !GetImport().GetTextImport()->IsInsideDeleteContext())
805cdf0e10cSrcweir     {
806ddde725dSArmin Le Grand         Reference < XShape > xShape( xPropSet, UNO_QUERY );
807ddde725dSArmin Le Grand 
808cdf0e10cSrcweir         GetImport().GetShapeImport()->shapeWithZIndexAdded( xShape, nZIndex );
809cdf0e10cSrcweir     }
810cdf0e10cSrcweir 
811cdf0e10cSrcweir     if( XML_TEXT_FRAME_TEXTBOX == nType )
812cdf0e10cSrcweir     {
813cdf0e10cSrcweir         xTextImportHelper->ConnectFrameChains( sName, sNextName, xPropSet );
814cdf0e10cSrcweir         Reference < XTextFrame > xTxtFrame( xPropSet, UNO_QUERY );
815cdf0e10cSrcweir         Reference < XText > xTxt = xTxtFrame->getText();
816cdf0e10cSrcweir         xOldTextCursor = xTextImportHelper->GetCursor();
817cdf0e10cSrcweir         xTextImportHelper->SetCursor( xTxt->createTextCursor() );
818cdf0e10cSrcweir 
819cdf0e10cSrcweir         // remember old list item and block (#89892#) and reset them
820cdf0e10cSrcweir         // for the text frame
821cdf0e10cSrcweir         xTextImportHelper->PushListContext();
822cdf0e10cSrcweir         mbListContextPushed = true;
823cdf0e10cSrcweir     }
824cdf0e10cSrcweir }
825cdf0e10cSrcweir 
CreateIfNotThere()826cdf0e10cSrcweir sal_Bool XMLTextFrameContext_Impl::CreateIfNotThere()
827cdf0e10cSrcweir {
828cdf0e10cSrcweir     if( !xPropSet.is() &&
829cdf0e10cSrcweir         ( XML_TEXT_FRAME_OBJECT_OLE == nType ||
830cdf0e10cSrcweir           XML_TEXT_FRAME_GRAPHIC == nType ) &&
831cdf0e10cSrcweir         xBase64Stream.is() && !bCreateFailed )
832cdf0e10cSrcweir     {
833cdf0e10cSrcweir         if( bOwnBase64Stream )
834cdf0e10cSrcweir             xBase64Stream->closeOutput();
835cdf0e10cSrcweir         Create( sal_True );
836cdf0e10cSrcweir     }
837cdf0e10cSrcweir 
838cdf0e10cSrcweir     return xPropSet.is();
839cdf0e10cSrcweir }
840cdf0e10cSrcweir 
XMLTextFrameContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<XAttributeList> & rAttrList,TextContentAnchorType eATyp,sal_uInt16 nNewType,const Reference<XAttributeList> & rFrameAttrList,bool bSetNameForFrame)841cdf0e10cSrcweir XMLTextFrameContext_Impl::XMLTextFrameContext_Impl(
842cdf0e10cSrcweir     SvXMLImport& rImport,
843cdf0e10cSrcweir     sal_uInt16 nPrfx, const OUString& rLName,
844cdf0e10cSrcweir     const Reference< XAttributeList > & rAttrList,
845cdf0e10cSrcweir     TextContentAnchorType eATyp,
846cdf0e10cSrcweir     sal_uInt16 nNewType,
847011bafbfSArmin Le Grand     const Reference< XAttributeList > & rFrameAttrList,
848011bafbfSArmin Le Grand     bool bSetNameForFrame)
849cdf0e10cSrcweir :   SvXMLImportContext( rImport, nPrfx, rLName )
850cdf0e10cSrcweir ,   mbListContextPushed( false )
851cdf0e10cSrcweir ,   sWidth(RTL_CONSTASCII_USTRINGPARAM("Width"))
852cdf0e10cSrcweir ,   sWidthType(RTL_CONSTASCII_USTRINGPARAM("WidthType"))
853cdf0e10cSrcweir ,   sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth"))
854cdf0e10cSrcweir ,   sHeight(RTL_CONSTASCII_USTRINGPARAM("Height"))
855cdf0e10cSrcweir ,   sRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("RelativeHeight"))
856cdf0e10cSrcweir ,   sSizeType(RTL_CONSTASCII_USTRINGPARAM("SizeType"))
857cdf0e10cSrcweir ,   sIsSyncWidthToHeight(RTL_CONSTASCII_USTRINGPARAM("IsSyncWidthToHeight"))
858cdf0e10cSrcweir ,   sIsSyncHeightToWidth(RTL_CONSTASCII_USTRINGPARAM("IsSyncHeightToWidth"))
859cdf0e10cSrcweir ,   sHoriOrient(RTL_CONSTASCII_USTRINGPARAM("HoriOrient"))
860cdf0e10cSrcweir ,   sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition"))
861cdf0e10cSrcweir ,   sVertOrient(RTL_CONSTASCII_USTRINGPARAM("VertOrient"))
862cdf0e10cSrcweir ,   sVertOrientPosition(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition"))
863cdf0e10cSrcweir ,   sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName"))
864cdf0e10cSrcweir ,   sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType"))
865cdf0e10cSrcweir ,   sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo"))
866cdf0e10cSrcweir ,   sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))
867cdf0e10cSrcweir ,   sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter"))
868cdf0e10cSrcweir // --> OD 2009-07-22 #i73249#
869cdf0e10cSrcweir //,   sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText"))
870cdf0e10cSrcweir ,   sTitle(RTL_CONSTASCII_USTRINGPARAM("Title"))
871cdf0e10cSrcweir ,   sDescription(RTL_CONSTASCII_USTRINGPARAM("Description"))
872cdf0e10cSrcweir // <--
873cdf0e10cSrcweir ,   sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName"))
874cdf0e10cSrcweir ,   sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation"))
875cdf0e10cSrcweir ,   sTextBoxServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))
876cdf0e10cSrcweir ,   sGraphicServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GraphicObject"))
877cdf0e10cSrcweir ,   nType( nNewType )
878cdf0e10cSrcweir ,   eAnchorType( eATyp )
879011bafbfSArmin Le Grand ,   mbSetNameForFrame(bSetNameForFrame)
880cdf0e10cSrcweir {
881cdf0e10cSrcweir     nX = 0;
882cdf0e10cSrcweir     nY = 0;
883cdf0e10cSrcweir     nWidth = 0;
884cdf0e10cSrcweir     nHeight = 0;
885cdf0e10cSrcweir     nZIndex = -1;
886cdf0e10cSrcweir     nPage = 0;
887cdf0e10cSrcweir     nRotation = 0;
888cdf0e10cSrcweir     nRelWidth = 0;
889cdf0e10cSrcweir     nRelHeight = 0;
890cdf0e10cSrcweir     bMayScript = sal_False;
891cdf0e10cSrcweir 
892cdf0e10cSrcweir     bMinHeight = sal_False;
893cdf0e10cSrcweir     bMinWidth = sal_False;
894cdf0e10cSrcweir     bSyncWidth = sal_False;
895cdf0e10cSrcweir     bSyncHeight = sal_False;
896cdf0e10cSrcweir     bCreateFailed = sal_False;
897cdf0e10cSrcweir     bOwnBase64Stream = sal_False;
898cdf0e10cSrcweir 
899cdf0e10cSrcweir     UniReference < XMLTextImportHelper > xTxtImport =
900cdf0e10cSrcweir         GetImport().GetTextImport();
901cdf0e10cSrcweir     const SvXMLTokenMap& rTokenMap =
902cdf0e10cSrcweir         xTxtImport->GetTextFrameAttrTokenMap();
903cdf0e10cSrcweir 
904cdf0e10cSrcweir     sal_Int16 nAttrCount = rAttrList.is() ? rAttrList->getLength() : 0;
905cdf0e10cSrcweir     sal_Int16 nTotalAttrCount = nAttrCount + (rFrameAttrList.is() ? rFrameAttrList->getLength() : 0);
906cdf0e10cSrcweir     for( sal_Int16 i=0; i < nTotalAttrCount; i++ )
907cdf0e10cSrcweir     {
908cdf0e10cSrcweir         const OUString& rAttrName =
909cdf0e10cSrcweir             i < nAttrCount ? rAttrList->getNameByIndex( i ) : rFrameAttrList->getNameByIndex( i-nAttrCount );
910cdf0e10cSrcweir         const OUString& rValue =
911cdf0e10cSrcweir             i < nAttrCount ? rAttrList->getValueByIndex( i ): rFrameAttrList->getValueByIndex( i-nAttrCount );
912cdf0e10cSrcweir 
913cdf0e10cSrcweir         OUString aLocalName;
914cdf0e10cSrcweir         sal_uInt16 nPrefix =
915cdf0e10cSrcweir             GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
916cdf0e10cSrcweir                                                             &aLocalName );
917cdf0e10cSrcweir         switch( rTokenMap.Get( nPrefix, aLocalName ) )
918cdf0e10cSrcweir         {
919cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_STYLE_NAME:
920cdf0e10cSrcweir             sStyleName = rValue;
921cdf0e10cSrcweir             break;
922cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_NAME:
923cdf0e10cSrcweir             sName = rValue;
924cdf0e10cSrcweir             break;
925cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_FRAME_NAME:
926cdf0e10cSrcweir             sFrameName = rValue;
927cdf0e10cSrcweir             break;
928cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_APPLET_NAME:
929cdf0e10cSrcweir             sAppletName = rValue;
930cdf0e10cSrcweir             break;
931cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_ANCHOR_TYPE:
932cdf0e10cSrcweir             if( TextContentAnchorType_AT_PARAGRAPH == eAnchorType ||
933cdf0e10cSrcweir                 TextContentAnchorType_AT_CHARACTER == eAnchorType ||
934cdf0e10cSrcweir                 TextContentAnchorType_AS_CHARACTER == eAnchorType )
935cdf0e10cSrcweir             {
936cdf0e10cSrcweir 
937cdf0e10cSrcweir                 TextContentAnchorType eNew;
938cdf0e10cSrcweir                 if( XMLAnchorTypePropHdl::convert( rValue, eNew ) &&
939cdf0e10cSrcweir                     ( TextContentAnchorType_AT_PARAGRAPH == eNew ||
940cdf0e10cSrcweir                       TextContentAnchorType_AT_CHARACTER == eNew ||
941cdf0e10cSrcweir                       TextContentAnchorType_AS_CHARACTER == eNew ||
942cdf0e10cSrcweir                       TextContentAnchorType_AT_PAGE == eNew) )
943cdf0e10cSrcweir                     eAnchorType = eNew;
944cdf0e10cSrcweir             }
945cdf0e10cSrcweir             break;
946cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_ANCHOR_PAGE_NUMBER:
947cdf0e10cSrcweir             {
948cdf0e10cSrcweir                 sal_Int32 nTmp;
949cdf0e10cSrcweir                 if( GetImport().GetMM100UnitConverter().
950cdf0e10cSrcweir                                 convertNumber( nTmp, rValue, 1, SHRT_MAX ) )
951cdf0e10cSrcweir                     nPage = (sal_Int16)nTmp;
952cdf0e10cSrcweir             }
953cdf0e10cSrcweir             break;
954cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_X:
955cdf0e10cSrcweir             GetImport().GetMM100UnitConverter().convertMeasure( nX, rValue );
956cdf0e10cSrcweir             break;
957cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_Y:
958cdf0e10cSrcweir             GetImport().GetMM100UnitConverter().convertMeasure( nY, rValue );
959cdf0e10cSrcweir             break;
960cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_WIDTH:
961cdf0e10cSrcweir             // relative widths are obsolete since SRC617. Remove them some day!
962cdf0e10cSrcweir             if( rValue.indexOf( '%' ) != -1 )
963cdf0e10cSrcweir             {
964cdf0e10cSrcweir                 sal_Int32 nTmp;
965cdf0e10cSrcweir                 GetImport().GetMM100UnitConverter().convertPercent( nTmp,
966cdf0e10cSrcweir                                                                     rValue );
967cdf0e10cSrcweir                 nRelWidth = (sal_Int16)nTmp;
968cdf0e10cSrcweir             }
969cdf0e10cSrcweir             else
970cdf0e10cSrcweir             {
971cdf0e10cSrcweir                 GetImport().GetMM100UnitConverter().convertMeasure( nWidth,
972cdf0e10cSrcweir                                                                     rValue, 0 );
973cdf0e10cSrcweir             }
974cdf0e10cSrcweir             break;
975cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_REL_WIDTH:
976cdf0e10cSrcweir             if( IsXMLToken(rValue, XML_SCALE) )
977cdf0e10cSrcweir             {
978cdf0e10cSrcweir                 bSyncWidth = sal_True;
979cdf0e10cSrcweir             }
980cdf0e10cSrcweir             else
981cdf0e10cSrcweir             {
982cdf0e10cSrcweir                 sal_Int32 nTmp;
983cdf0e10cSrcweir                 if( GetImport().GetMM100UnitConverter().
984cdf0e10cSrcweir                         convertPercent( nTmp, rValue ) )
985cdf0e10cSrcweir                     nRelWidth = (sal_Int16)nTmp;
986cdf0e10cSrcweir             }
987cdf0e10cSrcweir             break;
988cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_MIN_WIDTH:
989cdf0e10cSrcweir             if( rValue.indexOf( '%' ) != -1 )
990cdf0e10cSrcweir             {
991cdf0e10cSrcweir                 sal_Int32 nTmp;
992cdf0e10cSrcweir                 GetImport().GetMM100UnitConverter().convertPercent( nTmp,
993cdf0e10cSrcweir                                                                     rValue );
994cdf0e10cSrcweir                 nRelWidth = (sal_Int16)nTmp;
995cdf0e10cSrcweir             }
996cdf0e10cSrcweir             else
997cdf0e10cSrcweir             {
998cdf0e10cSrcweir                 GetImport().GetMM100UnitConverter().convertMeasure( nWidth,
999cdf0e10cSrcweir                                                                     rValue, 0 );
1000cdf0e10cSrcweir             }
1001cdf0e10cSrcweir             bMinWidth = sal_True;
1002cdf0e10cSrcweir             break;
1003cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_HEIGHT:
1004cdf0e10cSrcweir             // relative heights are obsolete since SRC617. Remove them some day!
1005cdf0e10cSrcweir             if( rValue.indexOf( '%' ) != -1 )
1006cdf0e10cSrcweir             {
1007cdf0e10cSrcweir                 sal_Int32 nTmp;
1008cdf0e10cSrcweir                 GetImport().GetMM100UnitConverter().convertPercent( nTmp,
1009cdf0e10cSrcweir                                                                     rValue );
1010cdf0e10cSrcweir                 nRelHeight = (sal_Int16)nTmp;
1011cdf0e10cSrcweir             }
1012cdf0e10cSrcweir             else
1013cdf0e10cSrcweir             {
1014cdf0e10cSrcweir                 GetImport().GetMM100UnitConverter().convertMeasure( nHeight,
1015cdf0e10cSrcweir                                                                     rValue, 0 );
1016cdf0e10cSrcweir             }
1017cdf0e10cSrcweir             break;
1018cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_REL_HEIGHT:
1019cdf0e10cSrcweir             if( IsXMLToken( rValue, XML_SCALE ) )
1020cdf0e10cSrcweir             {
1021cdf0e10cSrcweir                 bSyncHeight = sal_True;
1022cdf0e10cSrcweir             }
1023cdf0e10cSrcweir             else if( IsXMLToken( rValue, XML_SCALE_MIN ) )
1024cdf0e10cSrcweir             {
1025cdf0e10cSrcweir                 bSyncHeight = sal_True;
1026cdf0e10cSrcweir                 bMinHeight = sal_True;
1027cdf0e10cSrcweir             }
1028cdf0e10cSrcweir             else
1029cdf0e10cSrcweir             {
1030cdf0e10cSrcweir                 sal_Int32 nTmp;
1031cdf0e10cSrcweir                 if( GetImport().GetMM100UnitConverter().
1032cdf0e10cSrcweir                         convertPercent( nTmp, rValue ) )
1033cdf0e10cSrcweir                     nRelHeight = (sal_Int16)nTmp;
1034cdf0e10cSrcweir             }
1035cdf0e10cSrcweir             break;
1036cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_MIN_HEIGHT:
1037cdf0e10cSrcweir             if( rValue.indexOf( '%' ) != -1 )
1038cdf0e10cSrcweir             {
1039cdf0e10cSrcweir                 sal_Int32 nTmp;
1040cdf0e10cSrcweir                 GetImport().GetMM100UnitConverter().convertPercent( nTmp,
1041cdf0e10cSrcweir                                                                     rValue );
1042cdf0e10cSrcweir                 nRelHeight = (sal_Int16)nTmp;
1043cdf0e10cSrcweir             }
1044cdf0e10cSrcweir             else
1045cdf0e10cSrcweir             {
1046cdf0e10cSrcweir                 GetImport().GetMM100UnitConverter().convertMeasure( nHeight,
1047cdf0e10cSrcweir                                                                     rValue, 0 );
1048cdf0e10cSrcweir             }
1049cdf0e10cSrcweir             bMinHeight = sal_True;
1050cdf0e10cSrcweir             break;
1051cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_Z_INDEX:
1052cdf0e10cSrcweir             GetImport().GetMM100UnitConverter().convertNumber( nZIndex, rValue, -1 );
1053cdf0e10cSrcweir             break;
1054cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_NEXT_CHAIN_NAME:
1055cdf0e10cSrcweir             sNextName = rValue;
1056cdf0e10cSrcweir             break;
1057cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_HREF:
1058cdf0e10cSrcweir             sHRef = rValue;
1059cdf0e10cSrcweir             break;
1060cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_FILTER_NAME:
1061cdf0e10cSrcweir             sFilterName = rValue;
1062cdf0e10cSrcweir             break;
1063cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_TRANSFORM:
1064cdf0e10cSrcweir             {
1065cdf0e10cSrcweir                 OUString sValue( rValue );
1066cdf0e10cSrcweir                 sValue.trim();
1067cdf0e10cSrcweir                 const OUString aRotate(GetXMLToken(XML_ROTATE));
1068cdf0e10cSrcweir                 const sal_Int32 nRotateLen(aRotate.getLength());
1069cdf0e10cSrcweir                 sal_Int32 nLen = sValue.getLength();
1070cdf0e10cSrcweir                 if( nLen >= nRotateLen+3 &&
1071cdf0e10cSrcweir                     0 == sValue.compareTo( aRotate, nRotateLen ) &&
1072cdf0e10cSrcweir                     '(' == sValue[nRotateLen] &&
1073cdf0e10cSrcweir                     ')' == sValue[nLen-1] )
1074cdf0e10cSrcweir                 {
1075cdf0e10cSrcweir                     sValue = sValue.copy( nRotateLen+1, nLen-(nRotateLen+2) );
1076cdf0e10cSrcweir                     sValue.trim();
1077cdf0e10cSrcweir                     sal_Int32 nVal;
1078cdf0e10cSrcweir                     if( GetImport().GetMM100UnitConverter().convertNumber( nVal, sValue ) )
1079cdf0e10cSrcweir                         nRotation = (sal_Int16)(nVal % 360 );
1080cdf0e10cSrcweir                 }
1081cdf0e10cSrcweir             }
1082cdf0e10cSrcweir             break;
1083cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_CODE:
1084cdf0e10cSrcweir             sCode = rValue;
1085cdf0e10cSrcweir             break;
1086cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_OBJECT:
1087cdf0e10cSrcweir             sObject = rValue;
1088cdf0e10cSrcweir             break;
1089cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_ARCHIVE:
1090cdf0e10cSrcweir             sArchive = rValue;
1091cdf0e10cSrcweir             break;
1092cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_MAY_SCRIPT:
1093cdf0e10cSrcweir             bMayScript = IsXMLToken( rValue, XML_TRUE );
1094cdf0e10cSrcweir             break;
1095cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_MIME_TYPE:
1096cdf0e10cSrcweir             sMimeType = rValue;
1097cdf0e10cSrcweir             break;
1098cdf0e10cSrcweir         case XML_TOK_TEXT_FRAME_NOTIFY_ON_UPDATE:
1099cdf0e10cSrcweir             sTblName = rValue;
1100cdf0e10cSrcweir             break;
1101cdf0e10cSrcweir         }
1102cdf0e10cSrcweir     }
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir     if( ( (XML_TEXT_FRAME_GRAPHIC == nType ||
1105cdf0e10cSrcweir            XML_TEXT_FRAME_OBJECT == nType ||
1106cdf0e10cSrcweir            XML_TEXT_FRAME_OBJECT_OLE == nType) &&
1107cdf0e10cSrcweir           !sHRef.getLength() ) ||
1108cdf0e10cSrcweir         ( XML_TEXT_FRAME_APPLET  == nType && !sCode.getLength() ) ||
1109cdf0e10cSrcweir         ( XML_TEXT_FRAME_PLUGIN == nType &&
1110cdf0e10cSrcweir           sHRef.getLength() == 0 && sMimeType.getLength() == 0 ) )
1111cdf0e10cSrcweir         return; // no URL: no image or OLE object
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir     Create( sal_True );
1114cdf0e10cSrcweir }
1115cdf0e10cSrcweir 
~XMLTextFrameContext_Impl()1116cdf0e10cSrcweir XMLTextFrameContext_Impl::~XMLTextFrameContext_Impl()
1117cdf0e10cSrcweir {
1118cdf0e10cSrcweir }
1119cdf0e10cSrcweir 
EndElement()1120cdf0e10cSrcweir void XMLTextFrameContext_Impl::EndElement()
1121cdf0e10cSrcweir {
1122cdf0e10cSrcweir     CreateIfNotThere();
1123cdf0e10cSrcweir 
1124cdf0e10cSrcweir     if( xOldTextCursor.is() )
1125cdf0e10cSrcweir     {
1126cdf0e10cSrcweir         GetImport().GetTextImport()->DeleteParagraph();
1127cdf0e10cSrcweir         GetImport().GetTextImport()->SetCursor( xOldTextCursor );
1128cdf0e10cSrcweir     }
1129cdf0e10cSrcweir 
1130cdf0e10cSrcweir     // reinstall old list item (if necessary) #89892#
1131cdf0e10cSrcweir     if (mbListContextPushed) {
1132cdf0e10cSrcweir         GetImport().GetTextImport()->PopListContext();
1133cdf0e10cSrcweir     }
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir     if (( nType == XML_TEXT_FRAME_APPLET || nType == XML_TEXT_FRAME_PLUGIN ) && xPropSet.is())
1136cdf0e10cSrcweir         GetImport().GetTextImport()->endAppletOrPlugin( xPropSet, aParamMap);
1137cdf0e10cSrcweir }
1138cdf0e10cSrcweir 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<XAttributeList> & xAttrList)1139cdf0e10cSrcweir SvXMLImportContext *XMLTextFrameContext_Impl::CreateChildContext(
1140cdf0e10cSrcweir         sal_uInt16 nPrefix,
1141cdf0e10cSrcweir         const OUString& rLocalName,
1142cdf0e10cSrcweir         const Reference< XAttributeList > & xAttrList )
1143cdf0e10cSrcweir {
1144cdf0e10cSrcweir     SvXMLImportContext *pContext = 0;
1145cdf0e10cSrcweir 
1146cdf0e10cSrcweir     if( XML_NAMESPACE_DRAW == nPrefix )
1147cdf0e10cSrcweir     {
1148cdf0e10cSrcweir         if ( (nType == XML_TEXT_FRAME_APPLET || nType == XML_TEXT_FRAME_PLUGIN) &&
1149cdf0e10cSrcweir               IsXMLToken( rLocalName, XML_PARAM ) )
1150cdf0e10cSrcweir         {
1151cdf0e10cSrcweir             pContext = new XMLTextFrameParam_Impl( GetImport(),
1152cdf0e10cSrcweir                                               nPrefix, rLocalName,
1153cdf0e10cSrcweir                                               xAttrList, nType, aParamMap );
1154cdf0e10cSrcweir         }
1155cdf0e10cSrcweir     }
1156cdf0e10cSrcweir     else if( (XML_NAMESPACE_OFFICE == nPrefix) )
1157cdf0e10cSrcweir     {
1158cdf0e10cSrcweir         if( IsXMLToken( rLocalName, XML_BINARY_DATA ) )
1159cdf0e10cSrcweir         {
1160cdf0e10cSrcweir             if( !xPropSet.is() && !xBase64Stream.is() && !bCreateFailed )
1161cdf0e10cSrcweir             {
1162cdf0e10cSrcweir                 switch( nType )
1163cdf0e10cSrcweir                 {
1164cdf0e10cSrcweir                 case XML_TEXT_FRAME_GRAPHIC:
1165cdf0e10cSrcweir                     xBase64Stream =
1166cdf0e10cSrcweir                         GetImport().GetStreamForGraphicObjectURLFromBase64();
1167cdf0e10cSrcweir                     break;
1168cdf0e10cSrcweir                 case XML_TEXT_FRAME_OBJECT_OLE:
1169cdf0e10cSrcweir                     xBase64Stream =
1170cdf0e10cSrcweir                         GetImport().GetStreamForEmbeddedObjectURLFromBase64();
1171cdf0e10cSrcweir                     break;
1172cdf0e10cSrcweir                 }
1173cdf0e10cSrcweir                 if( xBase64Stream.is() )
1174cdf0e10cSrcweir                     pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
1175cdf0e10cSrcweir                                                     rLocalName, xAttrList,
1176cdf0e10cSrcweir                                                     xBase64Stream );
1177cdf0e10cSrcweir             }
1178cdf0e10cSrcweir         }
1179cdf0e10cSrcweir     }
1180cdf0e10cSrcweir     // --> OD 2009-08-17 #i100480#
1181cdf0e10cSrcweir     // correction of condition which also avoids warnings.
1182cdf0e10cSrcweir     if( !pContext &&
1183cdf0e10cSrcweir         ( XML_TEXT_FRAME_OBJECT == nType &&
1184cdf0e10cSrcweir           ( ( XML_NAMESPACE_OFFICE == nPrefix &&
1185cdf0e10cSrcweir               IsXMLToken( rLocalName, XML_DOCUMENT ) ) ||
1186cdf0e10cSrcweir             ( XML_NAMESPACE_MATH == nPrefix &&
1187cdf0e10cSrcweir               IsXMLToken( rLocalName, XML_MATH ) ) ) ) )
1188cdf0e10cSrcweir     // <--
1189cdf0e10cSrcweir     {
1190cdf0e10cSrcweir         if( !xPropSet.is() && !bCreateFailed )
1191cdf0e10cSrcweir         {
1192cdf0e10cSrcweir             XMLEmbeddedObjectImportContext *pEContext =
1193cdf0e10cSrcweir                 new XMLEmbeddedObjectImportContext( GetImport(), nPrefix,
1194cdf0e10cSrcweir                                                     rLocalName, xAttrList );
1195cdf0e10cSrcweir             sFilterService = pEContext->GetFilterServiceName();
1196cdf0e10cSrcweir             if( sFilterService.getLength() != 0 )
1197cdf0e10cSrcweir             {
1198cdf0e10cSrcweir                 Create( sal_False );
1199cdf0e10cSrcweir                 if( xPropSet.is() )
1200cdf0e10cSrcweir                 {
1201cdf0e10cSrcweir                     Reference < XEmbeddedObjectSupplier > xEOS( xPropSet,
1202cdf0e10cSrcweir                                                                 UNO_QUERY );
1203cdf0e10cSrcweir                     OSL_ENSURE( xEOS.is(),
1204cdf0e10cSrcweir                             "no embedded object supplier for own object" );
1205cdf0e10cSrcweir                     Reference<com::sun::star::lang::XComponent> aXComponent(xEOS->getEmbeddedObject());
1206cdf0e10cSrcweir                     pEContext->SetComponent( aXComponent );
1207cdf0e10cSrcweir                 }
1208cdf0e10cSrcweir             }
1209cdf0e10cSrcweir             pContext = pEContext;
1210cdf0e10cSrcweir         }
1211cdf0e10cSrcweir     }
1212cdf0e10cSrcweir     if( !pContext && xOldTextCursor.is() )  // text-box
1213cdf0e10cSrcweir         pContext = GetImport().GetTextImport()->CreateTextChildContext(
1214cdf0e10cSrcweir                             GetImport(), nPrefix, rLocalName, xAttrList,
1215cdf0e10cSrcweir                             XML_TEXT_TYPE_TEXTBOX );
1216cdf0e10cSrcweir 
1217cdf0e10cSrcweir     if( !pContext )
1218cdf0e10cSrcweir         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1219cdf0e10cSrcweir 
1220cdf0e10cSrcweir     return pContext;
1221cdf0e10cSrcweir }
1222cdf0e10cSrcweir 
Characters(const OUString & rChars)1223cdf0e10cSrcweir void XMLTextFrameContext_Impl::Characters( const OUString& rChars )
1224cdf0e10cSrcweir {
1225cdf0e10cSrcweir     if( ( XML_TEXT_FRAME_OBJECT_OLE == nType ||
1226cdf0e10cSrcweir           XML_TEXT_FRAME_GRAPHIC == nType) &&
1227cdf0e10cSrcweir         !xPropSet.is() && !bCreateFailed )
1228cdf0e10cSrcweir     {
1229cdf0e10cSrcweir         OUString sTrimmedChars( rChars. trim() );
1230cdf0e10cSrcweir         if( sTrimmedChars.getLength() )
1231cdf0e10cSrcweir         {
1232cdf0e10cSrcweir             if( !xBase64Stream.is() )
1233cdf0e10cSrcweir             {
1234cdf0e10cSrcweir                 if( XML_TEXT_FRAME_GRAPHIC == nType )
1235cdf0e10cSrcweir                 {
1236cdf0e10cSrcweir                     xBase64Stream =
1237cdf0e10cSrcweir                         GetImport().GetStreamForGraphicObjectURLFromBase64();
1238cdf0e10cSrcweir                 }
1239cdf0e10cSrcweir                 else
1240cdf0e10cSrcweir                 {
1241cdf0e10cSrcweir                     xBase64Stream =
1242cdf0e10cSrcweir                         GetImport().GetStreamForEmbeddedObjectURLFromBase64();
1243cdf0e10cSrcweir                 }
1244cdf0e10cSrcweir                 if( xBase64Stream.is() )
1245cdf0e10cSrcweir                     bOwnBase64Stream = sal_True;
1246cdf0e10cSrcweir             }
1247cdf0e10cSrcweir             if( bOwnBase64Stream && xBase64Stream.is() )
1248cdf0e10cSrcweir             {
1249cdf0e10cSrcweir                 OUString sChars;
125024c56ab9SHerbert Dürr                 if( !sBase64CharsLeft.isEmpty() )
1251cdf0e10cSrcweir                 {
1252cdf0e10cSrcweir                     sChars = sBase64CharsLeft;
1253cdf0e10cSrcweir                     sChars += sTrimmedChars;
1254cdf0e10cSrcweir                     sBase64CharsLeft = OUString();
1255cdf0e10cSrcweir                 }
1256cdf0e10cSrcweir                 else
1257cdf0e10cSrcweir                 {
1258cdf0e10cSrcweir                     sChars = sTrimmedChars;
1259cdf0e10cSrcweir                 }
1260cdf0e10cSrcweir                 Sequence< sal_Int8 > aBuffer( (sChars.getLength() / 4) * 3 );
1261cdf0e10cSrcweir                 sal_Int32 nCharsDecoded =
1262cdf0e10cSrcweir                     GetImport().GetMM100UnitConverter().
1263cdf0e10cSrcweir                         decodeBase64SomeChars( aBuffer, sChars );
1264cdf0e10cSrcweir                 xBase64Stream->writeBytes( aBuffer );
1265cdf0e10cSrcweir                 if( nCharsDecoded != sChars.getLength() )
1266cdf0e10cSrcweir                     sBase64CharsLeft = sChars.copy( nCharsDecoded );
1267cdf0e10cSrcweir             }
1268cdf0e10cSrcweir         }
1269cdf0e10cSrcweir     }
1270cdf0e10cSrcweir }
1271cdf0e10cSrcweir 
SetHyperlink(const OUString & rHRef,const OUString & rName,const OUString & rTargetFrameName,sal_Bool bMap)1272cdf0e10cSrcweir void XMLTextFrameContext_Impl::SetHyperlink( const OUString& rHRef,
1273cdf0e10cSrcweir                        const OUString& rName,
1274cdf0e10cSrcweir                        const OUString& rTargetFrameName,
1275cdf0e10cSrcweir                        sal_Bool bMap )
1276cdf0e10cSrcweir {
1277cdf0e10cSrcweir     static ::rtl::OUString s_HyperLinkURL(
1278cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL"));
1279cdf0e10cSrcweir     static ::rtl::OUString s_HyperLinkName(
1280cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("HyperLinkName"));
1281cdf0e10cSrcweir     static ::rtl::OUString s_HyperLinkTarget(
1282cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("HyperLinkTarget"));
1283cdf0e10cSrcweir     static ::rtl::OUString s_ServerMap(
1284cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("ServerMap"));
1285cdf0e10cSrcweir     if( !xPropSet.is() )
1286cdf0e10cSrcweir         return;
1287cdf0e10cSrcweir 
1288cdf0e10cSrcweir     UniReference< XMLTextImportHelper > xTxtImp = GetImport().GetTextImport();
1289cdf0e10cSrcweir     Reference < XPropertySetInfo > xPropSetInfo =
1290cdf0e10cSrcweir         xPropSet->getPropertySetInfo();
1291cdf0e10cSrcweir     if( !xPropSetInfo.is() ||
1292cdf0e10cSrcweir         !xPropSetInfo->hasPropertyByName(s_HyperLinkURL))
1293cdf0e10cSrcweir         return;
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir     Any aAny;
1296cdf0e10cSrcweir     aAny <<= rHRef;
1297cdf0e10cSrcweir     xPropSet->setPropertyValue( s_HyperLinkURL, aAny );
1298cdf0e10cSrcweir 
1299cdf0e10cSrcweir     if (xPropSetInfo->hasPropertyByName(s_HyperLinkName))
1300cdf0e10cSrcweir     {
1301cdf0e10cSrcweir         aAny <<= rName;
1302cdf0e10cSrcweir         xPropSet->setPropertyValue(s_HyperLinkName, aAny);
1303cdf0e10cSrcweir     }
1304cdf0e10cSrcweir 
1305cdf0e10cSrcweir     if (xPropSetInfo->hasPropertyByName(s_HyperLinkTarget))
1306cdf0e10cSrcweir     {
1307cdf0e10cSrcweir         aAny <<= rTargetFrameName;
1308cdf0e10cSrcweir         xPropSet->setPropertyValue( s_HyperLinkTarget, aAny );
1309cdf0e10cSrcweir     }
1310cdf0e10cSrcweir 
1311cdf0e10cSrcweir     if (xPropSetInfo->hasPropertyByName(s_ServerMap))
1312cdf0e10cSrcweir     {
1313cdf0e10cSrcweir         aAny.setValue( &bMap, ::getBooleanCppuType() );
1314cdf0e10cSrcweir         xPropSet->setPropertyValue(s_ServerMap, aAny);
1315cdf0e10cSrcweir     }
1316cdf0e10cSrcweir }
1317cdf0e10cSrcweir 
1318cdf0e10cSrcweir // --> OD 2009-07-22 #i73249#
SetTitle(const OUString & rTitle)1319cdf0e10cSrcweir void XMLTextFrameContext_Impl::SetTitle( const OUString& rTitle )
1320cdf0e10cSrcweir {
1321cdf0e10cSrcweir     if ( xPropSet.is() )
1322cdf0e10cSrcweir     {
1323cdf0e10cSrcweir         Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1324cdf0e10cSrcweir         if( xPropSetInfo->hasPropertyByName( sTitle ) )
1325cdf0e10cSrcweir         {
1326cdf0e10cSrcweir             xPropSet->setPropertyValue( sTitle, makeAny( rTitle ) );
1327cdf0e10cSrcweir         }
1328cdf0e10cSrcweir     }
1329cdf0e10cSrcweir }
1330cdf0e10cSrcweir 
SetDesc(const OUString & rDesc)1331cdf0e10cSrcweir void XMLTextFrameContext_Impl::SetDesc( const OUString& rDesc )
1332cdf0e10cSrcweir {
1333cdf0e10cSrcweir     if ( xPropSet.is() )
1334cdf0e10cSrcweir     {
1335cdf0e10cSrcweir         Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1336cdf0e10cSrcweir         if( xPropSetInfo->hasPropertyByName( sDescription ) )
1337cdf0e10cSrcweir         {
1338cdf0e10cSrcweir             xPropSet->setPropertyValue( sDescription, makeAny( rDesc ) );
1339cdf0e10cSrcweir         }
1340cdf0e10cSrcweir     }
1341cdf0e10cSrcweir }
1342cdf0e10cSrcweir // <--
1343cdf0e10cSrcweir 
1344cdf0e10cSrcweir //-----------------------------------------------------------------------------------------------------
1345cdf0e10cSrcweir 
1346cdf0e10cSrcweir TYPEINIT1( XMLTextFrameContext, SvXMLImportContext );
1347cdf0e10cSrcweir 
removeGraphicFromImportContext(const SvXMLImportContext & rContext) const1348ddde725dSArmin Le Grand void XMLTextFrameContext::removeGraphicFromImportContext(const SvXMLImportContext& rContext) const
1349ddde725dSArmin Le Grand {
1350ddde725dSArmin Le Grand     const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl = dynamic_cast< const XMLTextFrameContext_Impl* >(&rContext);
1351ddde725dSArmin Le Grand 
1352ddde725dSArmin Le Grand     if(pXMLTextFrameContext_Impl)
1353ddde725dSArmin Le Grand     {
1354ddde725dSArmin Le Grand         try
1355ddde725dSArmin Le Grand         {
1356ddde725dSArmin Le Grand             // just dispose to delete
1357ddde725dSArmin Le Grand             uno::Reference< lang::XComponent > xComp(pXMLTextFrameContext_Impl->GetPropSet(), UNO_QUERY);
1358ddde725dSArmin Le Grand 
1359ddde725dSArmin Le Grand             if(xComp.is())
1360ddde725dSArmin Le Grand             {
1361ddde725dSArmin Le Grand                 xComp->dispose();
1362ddde725dSArmin Le Grand             }
1363ddde725dSArmin Le Grand         }
1364ddde725dSArmin Le Grand         catch( uno::Exception& )
1365ddde725dSArmin Le Grand         {
1366ddde725dSArmin Le Grand             DBG_ERROR( "Error in cleanup of multiple graphic object import (!)" );
1367ddde725dSArmin Le Grand         }
1368ddde725dSArmin Le Grand     }
1369ddde725dSArmin Le Grand }
1370ddde725dSArmin Le Grand 
getGraphicURLFromImportContext(const SvXMLImportContext & rContext) const1371ddde725dSArmin Le Grand rtl::OUString XMLTextFrameContext::getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const
1372ddde725dSArmin Le Grand {
1373ddde725dSArmin Le Grand     rtl::OUString aRetval;
1374ddde725dSArmin Le Grand     const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl = dynamic_cast< const XMLTextFrameContext_Impl* >(&rContext);
1375ddde725dSArmin Le Grand 
1376ddde725dSArmin Le Grand     if(pXMLTextFrameContext_Impl)
1377ddde725dSArmin Le Grand     {
1378ddde725dSArmin Le Grand         return pXMLTextFrameContext_Impl->GetHRef();
1379ddde725dSArmin Le Grand     }
1380ddde725dSArmin Le Grand 
1381ddde725dSArmin Le Grand     return aRetval;
1382ddde725dSArmin Le Grand }
1383ddde725dSArmin Le Grand 
CreateIfNotThere()1384cdf0e10cSrcweir sal_Bool XMLTextFrameContext::CreateIfNotThere()
1385cdf0e10cSrcweir {
1386cdf0e10cSrcweir     sal_Bool bRet = sal_False;
1387cdf0e10cSrcweir     SvXMLImportContext *pContext = &m_xImplContext;
1388cdf0e10cSrcweir     XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1389cdf0e10cSrcweir     if( pImpl )
1390cdf0e10cSrcweir         bRet = pImpl->CreateIfNotThere();
1391cdf0e10cSrcweir 
1392cdf0e10cSrcweir     return bRet;
1393cdf0e10cSrcweir }
1394cdf0e10cSrcweir 
CreateIfNotThere(::com::sun::star::uno::Reference<::com::sun::star::beans::XPropertySet> & rPropSet)1395cdf0e10cSrcweir sal_Bool XMLTextFrameContext::CreateIfNotThere( ::com::sun::star::uno::Reference <
1396cdf0e10cSrcweir         ::com::sun::star::beans::XPropertySet >& rPropSet )
1397cdf0e10cSrcweir {
1398cdf0e10cSrcweir     SvXMLImportContext *pContext = &m_xImplContext;
1399cdf0e10cSrcweir     XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1400cdf0e10cSrcweir     if( pImpl )
1401cdf0e10cSrcweir     {
1402cdf0e10cSrcweir         if( pImpl->CreateIfNotThere() )
1403cdf0e10cSrcweir             rPropSet = pImpl->GetPropSet();
1404cdf0e10cSrcweir     }
1405cdf0e10cSrcweir 
1406cdf0e10cSrcweir     return rPropSet.is();
1407cdf0e10cSrcweir }
1408cdf0e10cSrcweir 
XMLTextFrameContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<XAttributeList> & xAttrList,TextContentAnchorType eATyp)1409cdf0e10cSrcweir XMLTextFrameContext::XMLTextFrameContext(
1410cdf0e10cSrcweir         SvXMLImport& rImport,
1411cdf0e10cSrcweir         sal_uInt16 nPrfx, const OUString& rLName,
1412cdf0e10cSrcweir         const Reference< XAttributeList > & xAttrList,
1413cdf0e10cSrcweir         TextContentAnchorType eATyp )
1414cdf0e10cSrcweir :   SvXMLImportContext( rImport, nPrfx, rLName )
1415ddde725dSArmin Le Grand ,   multiImageImportHelper()
1416cdf0e10cSrcweir ,   m_xAttrList( new SvXMLAttributeList( xAttrList ) )
1417cdf0e10cSrcweir ,   m_pHyperlink( 0 )
1418cdf0e10cSrcweir // --> OD 2009-07-22 #i73249#
1419cdf0e10cSrcweir ,   m_sTitle()
1420cdf0e10cSrcweir ,   m_sDesc()
1421cdf0e10cSrcweir // <--
1422cdf0e10cSrcweir ,   m_eDefaultAnchorType( eATyp )
1423cdf0e10cSrcweir     // --> OD 2006-03-10 #i51726#
1424cdf0e10cSrcweir ,   m_HasAutomaticStyleWithoutParentStyle( sal_False )
1425cdf0e10cSrcweir     // <--
1426cdf0e10cSrcweir ,   m_bSupportsReplacement( sal_False )
1427cdf0e10cSrcweir {
1428cdf0e10cSrcweir     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1429cdf0e10cSrcweir     for( sal_Int16 i=0; i < nAttrCount; i++ )
1430cdf0e10cSrcweir     {
1431cdf0e10cSrcweir         const OUString& rAttrName = xAttrList->getNameByIndex( i );
1432cdf0e10cSrcweir 
1433cdf0e10cSrcweir         OUString aLocalName;
1434cdf0e10cSrcweir         sal_uInt16 nPrefix =
1435cdf0e10cSrcweir             GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName );
1436cdf0e10cSrcweir         // --> OD 2006-03-10 #i51726#
1437cdf0e10cSrcweir         // New distinguish attribute between Writer objects and Draw objects is:
1438cdf0e10cSrcweir         // Draw objects have an automatic style without a parent style
1439cdf0e10cSrcweir         if ( XML_NAMESPACE_DRAW == nPrefix &&
1440cdf0e10cSrcweir              IsXMLToken( aLocalName, XML_STYLE_NAME ) )
1441cdf0e10cSrcweir         {
1442cdf0e10cSrcweir             OUString aStyleName = xAttrList->getValueByIndex( i );
1443cdf0e10cSrcweir             if( aStyleName.getLength() )
1444cdf0e10cSrcweir             {
1445cdf0e10cSrcweir                 UniReference < XMLTextImportHelper > xTxtImport =
1446cdf0e10cSrcweir                                                     GetImport().GetTextImport();
1447cdf0e10cSrcweir                 XMLPropStyleContext* pStyle( 0L );
1448cdf0e10cSrcweir                 pStyle = xTxtImport->FindAutoFrameStyle( aStyleName );
1449cdf0e10cSrcweir                 if ( pStyle && !pStyle->GetParentName().getLength() )
1450cdf0e10cSrcweir                 {
1451cdf0e10cSrcweir                     m_HasAutomaticStyleWithoutParentStyle = sal_True;
1452cdf0e10cSrcweir                 }
1453cdf0e10cSrcweir             }
1454cdf0e10cSrcweir         }
1455cdf0e10cSrcweir         // <--
1456cdf0e10cSrcweir         else if ( XML_NAMESPACE_TEXT == nPrefix &&
1457cdf0e10cSrcweir                   IsXMLToken( aLocalName, XML_ANCHOR_TYPE ) )
1458cdf0e10cSrcweir         {
1459cdf0e10cSrcweir             TextContentAnchorType eNew;
1460cdf0e10cSrcweir             if( XMLAnchorTypePropHdl::convert( xAttrList->getValueByIndex(i),
1461cdf0e10cSrcweir                         eNew ) &&
1462cdf0e10cSrcweir                 ( TextContentAnchorType_AT_PARAGRAPH == eNew ||
1463cdf0e10cSrcweir                   TextContentAnchorType_AT_CHARACTER == eNew ||
1464cdf0e10cSrcweir                   TextContentAnchorType_AS_CHARACTER == eNew ||
1465cdf0e10cSrcweir                   TextContentAnchorType_AT_PAGE == eNew) )
1466cdf0e10cSrcweir                 m_eDefaultAnchorType = eNew;
1467cdf0e10cSrcweir         }
1468cdf0e10cSrcweir     }
1469cdf0e10cSrcweir }
1470cdf0e10cSrcweir 
~XMLTextFrameContext()1471cdf0e10cSrcweir XMLTextFrameContext::~XMLTextFrameContext()
1472cdf0e10cSrcweir {
1473cdf0e10cSrcweir     delete m_pHyperlink;
1474cdf0e10cSrcweir }
1475cdf0e10cSrcweir 
EndElement()1476cdf0e10cSrcweir void XMLTextFrameContext::EndElement()
1477cdf0e10cSrcweir {
1478ddde725dSArmin Le Grand     /// solve if multiple image child contexts were imported
1479598d8f9fSArmin Le Grand     /// the winner is returned, if something has yet to be done with it
1480*4d38e14bSArrigo Marchiori     SvXMLImportContext* pWinner = const_cast< SvXMLImportContext* >( solveMultipleImages() );
1481011bafbfSArmin Le Grand 
1482011bafbfSArmin Le Grand     // #123261# see if the winner is a XMLTextFrameContext_Impl
1483*4d38e14bSArrigo Marchiori     XMLTextFrameContext_Impl* pImplWinner = dynamic_cast< XMLTextFrameContext_Impl* >(pWinner);
1484011bafbfSArmin Le Grand 
1485011bafbfSArmin Le Grand     if(pImplWinner)
1486011bafbfSArmin Le Grand     {
1487011bafbfSArmin Le Grand         // #123261# if yes, set name now, after the winner is identified (setting at each
1488011bafbfSArmin Le Grand         // candidate may run into problems due to colliding with efforts in the target to
1489011bafbfSArmin Le Grand         // avoid double names, so only set one name at one image and not at each)
1490*4d38e14bSArrigo Marchiori         pImplWinner->SetNameForFrameFromPropSet();
1491011bafbfSArmin Le Grand     }
1492ddde725dSArmin Le Grand 
1493cdf0e10cSrcweir     SvXMLImportContext *pContext = &m_xImplContext;
1494011bafbfSArmin Le Grand     XMLTextFrameContext_Impl *pImpl = dynamic_cast< XMLTextFrameContext_Impl* >(pContext);
1495011bafbfSArmin Le Grand 
1496cdf0e10cSrcweir     if( pImpl )
1497cdf0e10cSrcweir     {
1498cdf0e10cSrcweir         pImpl->CreateIfNotThere();
1499*4d38e14bSArrigo Marchiori     }
1500cdf0e10cSrcweir         // --> OD 2009-07-22 #i73249#
1501cdf0e10cSrcweir //        // alternative text
1502cdf0e10cSrcweir //        if( m_sDesc.getLength() )
1503cdf0e10cSrcweir //            pImpl->SetDesc( m_sDesc );
1504*4d38e14bSArrigo Marchiori 
1505*4d38e14bSArrigo Marchiori     // Bug #126768: set all properties to the winner
1506*4d38e14bSArrigo Marchiori     if ( pImplWinner ) {
1507*4d38e14bSArrigo Marchiori         pImpl = pImplWinner;
1508*4d38e14bSArrigo Marchiori     }
1509*4d38e14bSArrigo Marchiori     if ( pImpl ) {
1510cdf0e10cSrcweir         // svg:title
1511cdf0e10cSrcweir         if( m_sTitle.getLength() )
1512cdf0e10cSrcweir         {
1513cdf0e10cSrcweir             pImpl->SetTitle( m_sTitle );
1514cdf0e10cSrcweir         }
1515cdf0e10cSrcweir         if( m_sDesc.getLength() )
1516cdf0e10cSrcweir         {
1517cdf0e10cSrcweir             pImpl->SetDesc( m_sDesc );
1518cdf0e10cSrcweir         }
1519cdf0e10cSrcweir         // <--
1520cdf0e10cSrcweir 
1521cdf0e10cSrcweir         if( m_pHyperlink )
1522cdf0e10cSrcweir         {
1523cdf0e10cSrcweir             pImpl->SetHyperlink( m_pHyperlink->GetHRef(), m_pHyperlink->GetName(),
1524cdf0e10cSrcweir                           m_pHyperlink->GetTargetFrameName(), m_pHyperlink->GetMap() );
1525cdf0e10cSrcweir             delete m_pHyperlink;
1526cdf0e10cSrcweir             m_pHyperlink = 0;
1527cdf0e10cSrcweir         }
1528cdf0e10cSrcweir 
1529cdf0e10cSrcweir     }
1530cdf0e10cSrcweir }
1531cdf0e10cSrcweir 
CreateChildContext(sal_uInt16 p_nPrefix,const OUString & rLocalName,const Reference<XAttributeList> & xAttrList)1532cdf0e10cSrcweir SvXMLImportContext *XMLTextFrameContext::CreateChildContext(
1533cdf0e10cSrcweir         sal_uInt16 p_nPrefix,
1534cdf0e10cSrcweir         const OUString& rLocalName,
1535cdf0e10cSrcweir         const Reference< XAttributeList > & xAttrList )
1536cdf0e10cSrcweir {
1537cdf0e10cSrcweir     SvXMLImportContext *pContext = 0;
1538cdf0e10cSrcweir 
1539cdf0e10cSrcweir     if( !m_xImplContext.Is() )
1540cdf0e10cSrcweir     {
1541cdf0e10cSrcweir         // no child exists
1542cdf0e10cSrcweir         if( XML_NAMESPACE_DRAW == p_nPrefix )
1543cdf0e10cSrcweir         {
1544cdf0e10cSrcweir             sal_uInt16 nFrameType = USHRT_MAX;
1545cdf0e10cSrcweir             if( IsXMLToken( rLocalName, XML_TEXT_BOX ) )
1546cdf0e10cSrcweir                 nFrameType = XML_TEXT_FRAME_TEXTBOX;
1547cdf0e10cSrcweir             else if( IsXMLToken( rLocalName, XML_IMAGE ) )
1548cdf0e10cSrcweir                 nFrameType = XML_TEXT_FRAME_GRAPHIC;
1549cdf0e10cSrcweir             else if( IsXMLToken( rLocalName, XML_OBJECT ) )
1550cdf0e10cSrcweir                 nFrameType = XML_TEXT_FRAME_OBJECT;
1551cdf0e10cSrcweir             else if( IsXMLToken( rLocalName, XML_OBJECT_OLE ) )
1552cdf0e10cSrcweir                 nFrameType = XML_TEXT_FRAME_OBJECT_OLE;
1553cdf0e10cSrcweir             else if( IsXMLToken( rLocalName, XML_APPLET) )
1554cdf0e10cSrcweir                 nFrameType = XML_TEXT_FRAME_APPLET;
1555cdf0e10cSrcweir             else if( IsXMLToken( rLocalName, XML_PLUGIN ) )
1556cdf0e10cSrcweir                 nFrameType = XML_TEXT_FRAME_PLUGIN;
1557cdf0e10cSrcweir             else if( IsXMLToken( rLocalName, XML_FLOATING_FRAME ) )
1558cdf0e10cSrcweir                 nFrameType = XML_TEXT_FRAME_FLOATING_FRAME;
1559cdf0e10cSrcweir 
1560cdf0e10cSrcweir             if( USHRT_MAX != nFrameType )
1561cdf0e10cSrcweir             {
1562cdf0e10cSrcweir                 // --> OD 2006-03-10 #i51726#
1563cdf0e10cSrcweir                 if ( ( XML_TEXT_FRAME_TEXTBOX == nFrameType ||
1564cdf0e10cSrcweir                        XML_TEXT_FRAME_GRAPHIC == nFrameType ) &&
1565cdf0e10cSrcweir                      m_HasAutomaticStyleWithoutParentStyle )
1566cdf0e10cSrcweir                 // <--
1567cdf0e10cSrcweir                 {
1568cdf0e10cSrcweir                     Reference < XShapes > xShapes;
1569cdf0e10cSrcweir                     pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
1570cdf0e10cSrcweir                                     GetImport(), p_nPrefix, rLocalName, xAttrList, xShapes, m_xAttrList );
1571cdf0e10cSrcweir                 }
1572cdf0e10cSrcweir                 else if( XML_TEXT_FRAME_PLUGIN == nFrameType )
1573cdf0e10cSrcweir                 {
1574cdf0e10cSrcweir                     bool bMedia = false;
1575cdf0e10cSrcweir 
1576cdf0e10cSrcweir                     // check, if we have a media object
1577cdf0e10cSrcweir                     for( sal_Int16 n = 0, nAttrCount = ( xAttrList.is() ? xAttrList->getLength() : 0 ); n < nAttrCount; ++n )
1578cdf0e10cSrcweir                     {
1579cdf0e10cSrcweir                         OUString    aLocalName;
1580cdf0e10cSrcweir                         sal_uInt16  nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( n ), &aLocalName );
1581cdf0e10cSrcweir 
1582cdf0e10cSrcweir                         if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( aLocalName, XML_MIME_TYPE ) )
1583cdf0e10cSrcweir                         {
1584cdf0e10cSrcweir                             if( 0 == xAttrList->getValueByIndex( n ).compareToAscii( "application/vnd.sun.star.media" ) )
1585cdf0e10cSrcweir                                 bMedia = true;
1586cdf0e10cSrcweir 
1587cdf0e10cSrcweir                             // leave this loop
1588cdf0e10cSrcweir                             n = nAttrCount - 1;
1589cdf0e10cSrcweir                         }
1590cdf0e10cSrcweir                     }
1591cdf0e10cSrcweir 
1592cdf0e10cSrcweir                     if( bMedia )
1593cdf0e10cSrcweir                     {
1594cdf0e10cSrcweir                         Reference < XShapes > xShapes;
1595cdf0e10cSrcweir                         pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
1596cdf0e10cSrcweir                                         GetImport(), p_nPrefix, rLocalName, xAttrList, xShapes, m_xAttrList );
1597cdf0e10cSrcweir                     }
1598cdf0e10cSrcweir                 }
1599cdf0e10cSrcweir                 else if( XML_TEXT_FRAME_OBJECT == nFrameType ||
1600cdf0e10cSrcweir                          XML_TEXT_FRAME_OBJECT_OLE == nFrameType )
1601cdf0e10cSrcweir                 {
1602cdf0e10cSrcweir                     m_bSupportsReplacement = sal_True;
1603cdf0e10cSrcweir                 }
1604ddde725dSArmin Le Grand                 else if(XML_TEXT_FRAME_GRAPHIC == nFrameType)
1605ddde725dSArmin Le Grand                 {
1606ddde725dSArmin Le Grand                     setSupportsMultipleContents(IsXMLToken(rLocalName, XML_IMAGE));
1607ddde725dSArmin Le Grand                 }
1608cdf0e10cSrcweir 
1609cdf0e10cSrcweir                 if( !pContext )
1610cdf0e10cSrcweir                 {
1611011bafbfSArmin Le Grand                     pContext = new XMLTextFrameContext_Impl(
1612011bafbfSArmin Le Grand                         GetImport(),
1613011bafbfSArmin Le Grand                         p_nPrefix,
1614011bafbfSArmin Le Grand                         rLocalName,
1615011bafbfSArmin Le Grand                         xAttrList,
1616cdf0e10cSrcweir                         m_eDefaultAnchorType,
1617cdf0e10cSrcweir                         nFrameType,
1618011bafbfSArmin Le Grand                         m_xAttrList,
1619011bafbfSArmin Le Grand                         !getSupportsMultipleContents());
1620cdf0e10cSrcweir                 }
1621cdf0e10cSrcweir 
1622cdf0e10cSrcweir                 m_xImplContext = pContext;
1623ddde725dSArmin Le Grand 
1624ddde725dSArmin Le Grand                 if(getSupportsMultipleContents() && XML_TEXT_FRAME_GRAPHIC == nFrameType)
1625ddde725dSArmin Le Grand                 {
1626ddde725dSArmin Le Grand                     addContent(*m_xImplContext);
1627cdf0e10cSrcweir                 }
1628cdf0e10cSrcweir             }
1629cdf0e10cSrcweir         }
1630ddde725dSArmin Le Grand     }
1631ddde725dSArmin Le Grand     else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW == p_nPrefix && IsXMLToken(rLocalName, XML_IMAGE))
1632ddde725dSArmin Le Grand     {
1633ddde725dSArmin Le Grand         // read another image
1634ddde725dSArmin Le Grand         pContext = new XMLTextFrameContext_Impl(
1635011bafbfSArmin Le Grand             GetImport(),
1636011bafbfSArmin Le Grand             p_nPrefix,
1637011bafbfSArmin Le Grand             rLocalName,
1638011bafbfSArmin Le Grand             xAttrList,
1639011bafbfSArmin Le Grand             m_eDefaultAnchorType,
1640011bafbfSArmin Le Grand             XML_TEXT_FRAME_GRAPHIC,
1641011bafbfSArmin Le Grand             m_xAttrList,
1642011bafbfSArmin Le Grand             false);
1643ddde725dSArmin Le Grand 
1644ddde725dSArmin Le Grand         m_xImplContext = pContext;
1645ddde725dSArmin Le Grand         addContent(*m_xImplContext);
1646ddde725dSArmin Le Grand     }
1647cdf0e10cSrcweir     else if( m_bSupportsReplacement && !m_xReplImplContext &&
1648cdf0e10cSrcweir              XML_NAMESPACE_DRAW == p_nPrefix &&
1649cdf0e10cSrcweir              IsXMLToken( rLocalName, XML_IMAGE ) )
1650cdf0e10cSrcweir     {
1651cdf0e10cSrcweir         // read replacement image
1652cdf0e10cSrcweir         Reference < XPropertySet > xPropSet;
1653cdf0e10cSrcweir         if( CreateIfNotThere( xPropSet ) )
1654cdf0e10cSrcweir         {
1655cdf0e10cSrcweir             pContext = new XMLReplacementImageContext( GetImport(),
1656cdf0e10cSrcweir                                 p_nPrefix, rLocalName, xAttrList, xPropSet );
1657cdf0e10cSrcweir             m_xReplImplContext = pContext;
1658cdf0e10cSrcweir         }
1659cdf0e10cSrcweir     }
1660cdf0e10cSrcweir     else if( m_xImplContext->ISA( XMLTextFrameContext_Impl ) )
1661cdf0e10cSrcweir     {
1662cdf0e10cSrcweir         // the child is a writer frame
1663cdf0e10cSrcweir         if( XML_NAMESPACE_SVG == p_nPrefix )
1664cdf0e10cSrcweir         {
1665cdf0e10cSrcweir             // --> OD 2009-07-22 #i73249#
1666cdf0e10cSrcweir //            bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion();
1667cdf0e10cSrcweir //            if( IsXMLToken( rLocalName, bOld ? XML_DESC : XML_TITLE ) )
1668cdf0e10cSrcweir //                pContext = new XMLTextFrameDescContext_Impl( GetImport(), p_nPrefix, rLocalName,
1669cdf0e10cSrcweir //                                                         xAttrList, m_sDesc );
1670cdf0e10cSrcweir             const bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion();
1671cdf0e10cSrcweir             if ( bOld )
1672cdf0e10cSrcweir             {
1673cdf0e10cSrcweir                 if ( IsXMLToken( rLocalName, XML_DESC ) )
1674cdf0e10cSrcweir                 {
1675cdf0e10cSrcweir                     pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(),
1676cdf0e10cSrcweir                                                                         p_nPrefix,
1677cdf0e10cSrcweir                                                                         rLocalName,
1678cdf0e10cSrcweir                                                                         m_sTitle );
1679cdf0e10cSrcweir                 }
1680cdf0e10cSrcweir             }
1681cdf0e10cSrcweir             else
1682cdf0e10cSrcweir             {
1683cdf0e10cSrcweir                 if( IsXMLToken( rLocalName, XML_TITLE ) )
1684cdf0e10cSrcweir                 {
1685cdf0e10cSrcweir                     pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(),
1686cdf0e10cSrcweir                                                                         p_nPrefix,
1687cdf0e10cSrcweir                                                                         rLocalName,
1688cdf0e10cSrcweir                                                                         m_sTitle );
1689cdf0e10cSrcweir                 }
1690cdf0e10cSrcweir                 else if ( IsXMLToken( rLocalName, XML_DESC ) )
1691cdf0e10cSrcweir                 {
1692cdf0e10cSrcweir                     pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(),
1693cdf0e10cSrcweir                                                                         p_nPrefix,
1694cdf0e10cSrcweir                                                                         rLocalName,
1695cdf0e10cSrcweir                                                                         m_sDesc );
1696cdf0e10cSrcweir                 }
1697cdf0e10cSrcweir             }
1698cdf0e10cSrcweir             // <--
1699cdf0e10cSrcweir         }
1700cdf0e10cSrcweir         else if( XML_NAMESPACE_DRAW == p_nPrefix )
1701cdf0e10cSrcweir         {
1702cdf0e10cSrcweir             Reference < XPropertySet > xPropSet;
1703cdf0e10cSrcweir             if( IsXMLToken( rLocalName, XML_CONTOUR_POLYGON ) )
1704cdf0e10cSrcweir             {
1705cdf0e10cSrcweir                 if( CreateIfNotThere( xPropSet ) )
1706cdf0e10cSrcweir                     pContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName,
1707cdf0e10cSrcweir                                                   xAttrList, xPropSet, sal_False );
1708cdf0e10cSrcweir             }
1709cdf0e10cSrcweir             else if( IsXMLToken( rLocalName, XML_CONTOUR_PATH ) )
1710cdf0e10cSrcweir             {
1711cdf0e10cSrcweir                 if( CreateIfNotThere( xPropSet ) )
1712cdf0e10cSrcweir                     pContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName,
1713cdf0e10cSrcweir                                                   xAttrList, xPropSet, sal_True );
1714cdf0e10cSrcweir             }
1715cdf0e10cSrcweir             else if( IsXMLToken( rLocalName, XML_IMAGE_MAP ) )
1716cdf0e10cSrcweir             {
1717cdf0e10cSrcweir                 if( CreateIfNotThere( xPropSet ) )
1718cdf0e10cSrcweir                     pContext = new XMLImageMapContext( GetImport(), p_nPrefix, rLocalName, xPropSet );
1719cdf0e10cSrcweir             }
1720cdf0e10cSrcweir         }
1721cdf0e10cSrcweir         else if( (XML_NAMESPACE_OFFICE == p_nPrefix) && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) )
1722cdf0e10cSrcweir         {
1723cdf0e10cSrcweir             // do we still have the frame object?
1724cdf0e10cSrcweir             Reference < XPropertySet > xPropSet;
1725cdf0e10cSrcweir             if( CreateIfNotThere( xPropSet ) )
1726cdf0e10cSrcweir             {
1727cdf0e10cSrcweir                 // is it an event supplier?
1728cdf0e10cSrcweir                 Reference<XEventsSupplier> xEventsSupplier(xPropSet, UNO_QUERY);
1729cdf0e10cSrcweir                 if (xEventsSupplier.is())
1730cdf0e10cSrcweir                 {
1731cdf0e10cSrcweir                     // OK, we have the events, so create the context
1732cdf0e10cSrcweir                     pContext = new XMLEventsImportContext(GetImport(), p_nPrefix,
1733cdf0e10cSrcweir                                                       rLocalName, xEventsSupplier);
1734cdf0e10cSrcweir                 }
1735cdf0e10cSrcweir             }
1736cdf0e10cSrcweir         }
1737cdf0e10cSrcweir     }
1738cdf0e10cSrcweir     else if( p_nPrefix == XML_NAMESPACE_SVG &&  // #i68101#
1739cdf0e10cSrcweir                 (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) )
1740cdf0e10cSrcweir     {
1741cdf0e10cSrcweir         pContext = m_xImplContext->CreateChildContext( p_nPrefix, rLocalName, xAttrList );
1742cdf0e10cSrcweir     }
1743cdf0e10cSrcweir     else
1744cdf0e10cSrcweir     {
1745cdf0e10cSrcweir         // the child is a drawing shape
1746cdf0e10cSrcweir         pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
1747cdf0e10cSrcweir                                     &m_xImplContext, p_nPrefix, rLocalName, xAttrList );
1748cdf0e10cSrcweir     }
1749cdf0e10cSrcweir 
1750cdf0e10cSrcweir     if( !pContext )
1751cdf0e10cSrcweir         pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName );
1752cdf0e10cSrcweir 
1753cdf0e10cSrcweir     return pContext;
1754cdf0e10cSrcweir }
1755cdf0e10cSrcweir 
SetHyperlink(const OUString & rHRef,const OUString & rName,const OUString & rTargetFrameName,sal_Bool bMap)1756cdf0e10cSrcweir void XMLTextFrameContext::SetHyperlink( const OUString& rHRef,
1757cdf0e10cSrcweir                        const OUString& rName,
1758cdf0e10cSrcweir                        const OUString& rTargetFrameName,
1759cdf0e10cSrcweir                        sal_Bool bMap )
1760cdf0e10cSrcweir {
1761cdf0e10cSrcweir     OSL_ENSURE( !m_pHyperlink, "recursive SetHyperlink call" );
1762cdf0e10cSrcweir     delete m_pHyperlink;
1763cdf0e10cSrcweir     m_pHyperlink = new XMLTextFrameContextHyperlink_Impl(
1764cdf0e10cSrcweir                 rHRef, rName, rTargetFrameName, bMap );
1765cdf0e10cSrcweir }
1766cdf0e10cSrcweir 
GetAnchorType() const1767cdf0e10cSrcweir TextContentAnchorType XMLTextFrameContext::GetAnchorType() const
1768cdf0e10cSrcweir {
1769cdf0e10cSrcweir     SvXMLImportContext *pContext = &m_xImplContext;
1770cdf0e10cSrcweir     XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1771cdf0e10cSrcweir     if( pImpl )
1772cdf0e10cSrcweir         return pImpl->GetAnchorType();
1773cdf0e10cSrcweir     else
1774cdf0e10cSrcweir         return m_eDefaultAnchorType;
1775cdf0e10cSrcweir }
1776cdf0e10cSrcweir 
GetTextContent() const1777cdf0e10cSrcweir Reference < XTextContent > XMLTextFrameContext::GetTextContent() const
1778cdf0e10cSrcweir {
1779cdf0e10cSrcweir     Reference < XTextContent > xTxtCntnt;
1780cdf0e10cSrcweir     SvXMLImportContext *pContext = &m_xImplContext;
1781cdf0e10cSrcweir     XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1782cdf0e10cSrcweir     if( pImpl )
1783cdf0e10cSrcweir         xTxtCntnt.set( pImpl->GetPropSet(), UNO_QUERY );
1784cdf0e10cSrcweir 
1785cdf0e10cSrcweir     return xTxtCntnt;
1786cdf0e10cSrcweir }
1787cdf0e10cSrcweir 
1788cdf0e10cSrcweir // --> OD 2004-08-24 #33242#
GetShape() const1789cdf0e10cSrcweir Reference < XShape > XMLTextFrameContext::GetShape() const
1790cdf0e10cSrcweir {
1791cdf0e10cSrcweir     Reference < XShape > xShape;
1792cdf0e10cSrcweir     SvXMLImportContext* pContext = &m_xImplContext;
1793cdf0e10cSrcweir     SvXMLShapeContext* pImpl = PTR_CAST( SvXMLShapeContext, pContext );
1794cdf0e10cSrcweir     if ( pImpl )
1795cdf0e10cSrcweir     {
1796cdf0e10cSrcweir         xShape = pImpl->getShape();
1797cdf0e10cSrcweir     }
1798cdf0e10cSrcweir 
1799cdf0e10cSrcweir     return xShape;
1800cdf0e10cSrcweir }
1801cdf0e10cSrcweir // <--
1802