1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10efeef26fSAndrew Rist *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19efeef26fSAndrew Rist *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_sw.hxx"
24cdf0e10cSrcweir #include <hintids.hxx>
25cdf0e10cSrcweir #include <vcl/salbtype.hxx> // FRound
26cdf0e10cSrcweir #include <tools/urlobj.hxx>
27cdf0e10cSrcweir #include <svl/undo.hxx>
28cdf0e10cSrcweir #ifndef SVTOOLS_FSTATHELPER_HXX
29cdf0e10cSrcweir #include <svl/fstathelper.hxx>
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir #include <svtools/imap.hxx>
32cdf0e10cSrcweir #include <svtools/filter.hxx>
33cdf0e10cSrcweir #include <sot/storage.hxx>
34cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
35cdf0e10cSrcweir #include <editeng/boxitem.hxx>
36cdf0e10cSrcweir #include <sot/formats.hxx>
37cdf0e10cSrcweir #include <fmtfsize.hxx>
38cdf0e10cSrcweir #include <fmturl.hxx>
39cdf0e10cSrcweir #include <frmfmt.hxx>
40cdf0e10cSrcweir #include <doc.hxx>
41cdf0e10cSrcweir #include <frmatr.hxx>
42cdf0e10cSrcweir #include <grfatr.hxx>
43cdf0e10cSrcweir #include <swtypes.hxx>
44cdf0e10cSrcweir #include <ndgrf.hxx>
45cdf0e10cSrcweir #include <fmtcol.hxx>
46cdf0e10cSrcweir #include <hints.hxx>
47cdf0e10cSrcweir #include <swbaslnk.hxx>
48cdf0e10cSrcweir #include <pagefrm.hxx>
49cdf0e10cSrcweir #include <editsh.hxx>
50cdf0e10cSrcweir #include <pam.hxx>
51cdf0e10cSrcweir
52cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx>
53cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp>
54cdf0e10cSrcweir #include <com/sun/star/embed/XTransactedObject.hpp>
55cdf0e10cSrcweir #include <tools/link.hxx>
56cdf0e10cSrcweir #include <vcl/svapp.hxx>
57cdf0e10cSrcweir #include <com/sun/star/io/XSeekable.hpp>
58cdf0e10cSrcweir #include <retrieveinputstreamconsumer.hxx>
59172c67b2SArmin Le Grand #include <drawinglayer/processor2d/objectinfoextractor2d.hxx>
60172c67b2SArmin Le Grand #include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
61*d327e58aSArmin Le Grand #include <unotools/cacheoptions.hxx>
62172c67b2SArmin Le Grand
63cdf0e10cSrcweir using namespace com::sun::star;
64cdf0e10cSrcweir
65*d327e58aSArmin Le Grand #define SWAPGRAPHIC_TIMEOUT 5000
668a2cae91SOliver-Rainer Wittmann
67*d327e58aSArmin Le Grand // For comments see same method used in svx
getCacheTimeInMs()68*d327e58aSArmin Le Grand sal_uInt32 getCacheTimeInMs()
69*d327e58aSArmin Le Grand {
70*d327e58aSArmin Le Grand static bool bSetAtAll(true);
71*d327e58aSArmin Le Grand
72*d327e58aSArmin Le Grand if(bSetAtAll)
73*d327e58aSArmin Le Grand {
74*d327e58aSArmin Le Grand static bool bSetToPreferenceTime(true);
75*d327e58aSArmin Le Grand
76*d327e58aSArmin Le Grand if(bSetToPreferenceTime)
77*d327e58aSArmin Le Grand {
78*d327e58aSArmin Le Grand const SvtCacheOptions aCacheOptions;
79*d327e58aSArmin Le Grand const sal_Int32 nSeconds(aCacheOptions.GetGraphicManagerObjectReleaseTime());
80*d327e58aSArmin Le Grand
81*d327e58aSArmin Le Grand return nSeconds * 1000 / 12;
82*d327e58aSArmin Le Grand }
83*d327e58aSArmin Le Grand else
84*d327e58aSArmin Le Grand {
85*d327e58aSArmin Le Grand return SWAPGRAPHIC_TIMEOUT;
86*d327e58aSArmin Le Grand }
87*d327e58aSArmin Le Grand }
88*d327e58aSArmin Le Grand
89*d327e58aSArmin Le Grand return 0;
90*d327e58aSArmin Le Grand }
913b5ba58cSOliver-Rainer Wittmann
92cdf0e10cSrcweir // --------------------
93cdf0e10cSrcweir // SwGrfNode
94cdf0e10cSrcweir // --------------------
SwGrfNode(const SwNodeIndex & rWhere,const String & rGrfName,const String & rFltName,const Graphic * pGraphic,SwGrfFmtColl * pGrfColl,SwAttrSet * pAutoAttr)95cdf0e10cSrcweir SwGrfNode::SwGrfNode(
9657326f99SOliver-Rainer Wittmann const SwNodeIndex & rWhere,
9757326f99SOliver-Rainer Wittmann const String& rGrfName,
9857326f99SOliver-Rainer Wittmann const String& rFltName,
9957326f99SOliver-Rainer Wittmann const Graphic* pGraphic,
10057326f99SOliver-Rainer Wittmann SwGrfFmtColl *pGrfColl,
10157326f99SOliver-Rainer Wittmann SwAttrSet* pAutoAttr )
10257326f99SOliver-Rainer Wittmann : SwNoTxtNode( rWhere, ND_GRFNODE, pGrfColl, pAutoAttr ),
10357326f99SOliver-Rainer Wittmann maGrfObj(),
10457326f99SOliver-Rainer Wittmann mpReplacementGraphic( 0 ),
10557326f99SOliver-Rainer Wittmann mbLinkedInputStreamReady( false ),
10657326f99SOliver-Rainer Wittmann mbIsStreamReadOnly( sal_False )
107cdf0e10cSrcweir {
108*d327e58aSArmin Le Grand maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ), getCacheTimeInMs() );
10957326f99SOliver-Rainer Wittmann bInSwapIn = bChgTwipSize = bChgTwipSizeFromPixel = bLoadLowResGrf = bFrameInPaint = bScaleImageMap = sal_False;
110cdf0e10cSrcweir
111cdf0e10cSrcweir bGrafikArrived = sal_True;
11257326f99SOliver-Rainer Wittmann ReRead( rGrfName, rFltName, pGraphic, 0, sal_False );
113cdf0e10cSrcweir }
114cdf0e10cSrcweir
SwGrfNode(const SwNodeIndex & rWhere,const GraphicObject & rGrfObj,SwGrfFmtColl * pGrfColl,SwAttrSet * pAutoAttr)11557326f99SOliver-Rainer Wittmann SwGrfNode::SwGrfNode(
11657326f99SOliver-Rainer Wittmann const SwNodeIndex & rWhere,
11757326f99SOliver-Rainer Wittmann const GraphicObject& rGrfObj,
11857326f99SOliver-Rainer Wittmann SwGrfFmtColl *pGrfColl,
11957326f99SOliver-Rainer Wittmann SwAttrSet* pAutoAttr )
12057326f99SOliver-Rainer Wittmann : SwNoTxtNode( rWhere, ND_GRFNODE, pGrfColl, pAutoAttr ),
12157326f99SOliver-Rainer Wittmann maGrfObj( rGrfObj ),
12257326f99SOliver-Rainer Wittmann mpReplacementGraphic( 0 ),
12357326f99SOliver-Rainer Wittmann mbLinkedInputStreamReady( false ),
12457326f99SOliver-Rainer Wittmann mbIsStreamReadOnly( sal_False )
125cdf0e10cSrcweir {
12657326f99SOliver-Rainer Wittmann maGrfObj = rGrfObj;
127*d327e58aSArmin Le Grand maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ), getCacheTimeInMs() );
12857326f99SOliver-Rainer Wittmann if ( rGrfObj.HasUserData() && rGrfObj.IsSwappedOut() )
12957326f99SOliver-Rainer Wittmann maGrfObj.SetSwapState();
13057326f99SOliver-Rainer Wittmann bInSwapIn = bChgTwipSize = bChgTwipSizeFromPixel = bLoadLowResGrf = bFrameInPaint = bScaleImageMap = sal_False;
13157326f99SOliver-Rainer Wittmann bGrafikArrived = sal_True;
132cdf0e10cSrcweir }
133cdf0e10cSrcweir
134cdf0e10cSrcweir // Konstruktor fuer den SW/G-Reader. Dieser ctor wird verwendet,
135cdf0e10cSrcweir // wenn eine gelinkte Grafik gelesen wird. Sie liest diese NICHT ein.
136cdf0e10cSrcweir
SwGrfNode(const SwNodeIndex & rWhere,const String & rGrfName,const String & rFltName,SwGrfFmtColl * pGrfColl,SwAttrSet * pAutoAttr)1378a2cae91SOliver-Rainer Wittmann SwGrfNode::SwGrfNode(
1388a2cae91SOliver-Rainer Wittmann const SwNodeIndex & rWhere,
1398a2cae91SOliver-Rainer Wittmann const String& rGrfName,
1408a2cae91SOliver-Rainer Wittmann const String& rFltName,
1418a2cae91SOliver-Rainer Wittmann SwGrfFmtColl *pGrfColl,
1428a2cae91SOliver-Rainer Wittmann SwAttrSet* pAutoAttr )
1438a2cae91SOliver-Rainer Wittmann :
1448a2cae91SOliver-Rainer Wittmann SwNoTxtNode( rWhere, ND_GRFNODE, pGrfColl, pAutoAttr ),
1458a2cae91SOliver-Rainer Wittmann maGrfObj(),
1468a2cae91SOliver-Rainer Wittmann mpReplacementGraphic( 0 ),
1478a2cae91SOliver-Rainer Wittmann mbLinkedInputStreamReady( false ),
1488a2cae91SOliver-Rainer Wittmann mbIsStreamReadOnly( sal_False )
149cdf0e10cSrcweir {
150*d327e58aSArmin Le Grand maGrfObj.SetSwapStreamHdl( LINK( this, SwGrfNode, SwapGraphic ), getCacheTimeInMs() );
1518a2cae91SOliver-Rainer Wittmann
1528a2cae91SOliver-Rainer Wittmann Graphic aGrf;
1538a2cae91SOliver-Rainer Wittmann aGrf.SetDefaultType();
1548a2cae91SOliver-Rainer Wittmann maGrfObj.SetGraphic( aGrf, rGrfName );
1558a2cae91SOliver-Rainer Wittmann
1568a2cae91SOliver-Rainer Wittmann bInSwapIn = bChgTwipSize = bChgTwipSizeFromPixel = bLoadLowResGrf =
1578a2cae91SOliver-Rainer Wittmann bFrameInPaint = bScaleImageMap = sal_False;
1588a2cae91SOliver-Rainer Wittmann bGrafikArrived = sal_True;
1598a2cae91SOliver-Rainer Wittmann
1608a2cae91SOliver-Rainer Wittmann InsertLink( rGrfName, rFltName );
1618a2cae91SOliver-Rainer Wittmann if ( IsLinkedFile() )
1628a2cae91SOliver-Rainer Wittmann {
1638a2cae91SOliver-Rainer Wittmann INetURLObject aUrl( rGrfName );
1648a2cae91SOliver-Rainer Wittmann if ( INET_PROT_FILE == aUrl.GetProtocol() &&
1658a2cae91SOliver-Rainer Wittmann FStatHelper::IsDocument( aUrl.GetMainURL( INetURLObject::NO_DECODE ) ) )
1668a2cae91SOliver-Rainer Wittmann {
1678a2cae91SOliver-Rainer Wittmann // File vorhanden, Verbindung herstellen ohne ein Update
1688a2cae91SOliver-Rainer Wittmann ( (SwBaseLink*) &refLink )->Connect();
1698a2cae91SOliver-Rainer Wittmann }
1708a2cae91SOliver-Rainer Wittmann }
171cdf0e10cSrcweir }
172cdf0e10cSrcweir
ReRead(const String & rGrfName,const String & rFltName,const Graphic * pGraphic,const GraphicObject * pGrfObj,sal_Bool bNewGrf)173cdf0e10cSrcweir sal_Bool SwGrfNode::ReRead(
1748a2cae91SOliver-Rainer Wittmann const String& rGrfName,
1758a2cae91SOliver-Rainer Wittmann const String& rFltName,
1768a2cae91SOliver-Rainer Wittmann const Graphic* pGraphic,
1778a2cae91SOliver-Rainer Wittmann const GraphicObject* pGrfObj,
178cdf0e10cSrcweir sal_Bool bNewGrf )
179cdf0e10cSrcweir {
1808a2cae91SOliver-Rainer Wittmann sal_Bool bReadGrf = sal_False, bSetTwipSize = sal_True;
181ddde725dSArmin Le Grand delete mpReplacementGraphic;
182ddde725dSArmin Le Grand mpReplacementGraphic = 0;
183cdf0e10cSrcweir
1848a2cae91SOliver-Rainer Wittmann ASSERT( pGraphic || pGrfObj || rGrfName.Len(),
1858a2cae91SOliver-Rainer Wittmann "GraphicNode without a name, Graphic or GraphicObject" );
1868a2cae91SOliver-Rainer Wittmann
1878a2cae91SOliver-Rainer Wittmann // ReadRead mit Namen
1888a2cae91SOliver-Rainer Wittmann if ( refLink.Is() )
1898a2cae91SOliver-Rainer Wittmann {
1908a2cae91SOliver-Rainer Wittmann ASSERT( !bInSwapIn, "ReRead: stehe noch im SwapIn" );
1918a2cae91SOliver-Rainer Wittmann
1928a2cae91SOliver-Rainer Wittmann if ( rGrfName.Len() )
1938a2cae91SOliver-Rainer Wittmann {
1948a2cae91SOliver-Rainer Wittmann // Besonderheit: steht im FltNamen DDE, handelt es sich um eine
1958a2cae91SOliver-Rainer Wittmann // DDE-gelinkte Grafik
1968a2cae91SOliver-Rainer Wittmann String sCmd( rGrfName );
1978a2cae91SOliver-Rainer Wittmann if ( rFltName.Len() )
1988a2cae91SOliver-Rainer Wittmann {
1998a2cae91SOliver-Rainer Wittmann sal_uInt16 nNewType;
2008a2cae91SOliver-Rainer Wittmann if ( rFltName.EqualsAscii( "DDE" ) )
2018a2cae91SOliver-Rainer Wittmann nNewType = OBJECT_CLIENT_DDE;
2028a2cae91SOliver-Rainer Wittmann else
2038a2cae91SOliver-Rainer Wittmann {
204cdf0e10cSrcweir sfx2::MakeLnkName( sCmd, 0, rGrfName, aEmptyStr, &rFltName );
2058a2cae91SOliver-Rainer Wittmann nNewType = OBJECT_CLIENT_GRF;
2068a2cae91SOliver-Rainer Wittmann }
2078a2cae91SOliver-Rainer Wittmann
2088a2cae91SOliver-Rainer Wittmann if ( nNewType != refLink->GetObjType() )
2098a2cae91SOliver-Rainer Wittmann {
2108a2cae91SOliver-Rainer Wittmann refLink->Disconnect();
2118a2cae91SOliver-Rainer Wittmann ( (SwBaseLink*) &refLink )->SetObjType( nNewType );
2128a2cae91SOliver-Rainer Wittmann }
2138a2cae91SOliver-Rainer Wittmann }
2148a2cae91SOliver-Rainer Wittmann
2158a2cae91SOliver-Rainer Wittmann refLink->SetLinkSourceName( sCmd );
2168a2cae91SOliver-Rainer Wittmann }
2178a2cae91SOliver-Rainer Wittmann else // kein Name mehr, Link aufheben
2188a2cae91SOliver-Rainer Wittmann {
2198a2cae91SOliver-Rainer Wittmann GetDoc()->GetLinkManager().Remove( refLink );
2208a2cae91SOliver-Rainer Wittmann refLink.Clear();
2218a2cae91SOliver-Rainer Wittmann }
2228a2cae91SOliver-Rainer Wittmann
2238a2cae91SOliver-Rainer Wittmann if ( pGraphic )
2248a2cae91SOliver-Rainer Wittmann {
2258a2cae91SOliver-Rainer Wittmann maGrfObj.SetGraphic( *pGraphic, rGrfName );
226172c67b2SArmin Le Grand onGraphicChanged();
2278a2cae91SOliver-Rainer Wittmann bReadGrf = sal_True;
2288a2cae91SOliver-Rainer Wittmann }
2298a2cae91SOliver-Rainer Wittmann else if ( pGrfObj )
2308a2cae91SOliver-Rainer Wittmann {
2318a2cae91SOliver-Rainer Wittmann maGrfObj = *pGrfObj;
2328a2cae91SOliver-Rainer Wittmann if ( pGrfObj->HasUserData() && pGrfObj->IsSwappedOut() )
2338a2cae91SOliver-Rainer Wittmann maGrfObj.SetSwapState();
2348a2cae91SOliver-Rainer Wittmann maGrfObj.SetLink( rGrfName );
235172c67b2SArmin Le Grand onGraphicChanged();
2368a2cae91SOliver-Rainer Wittmann bReadGrf = sal_True;
2378a2cae91SOliver-Rainer Wittmann }
2388a2cae91SOliver-Rainer Wittmann else
2398a2cae91SOliver-Rainer Wittmann {
2408a2cae91SOliver-Rainer Wittmann // MIB 25.02.97: Daten der alten Grafik zuruecksetzen, damit
2418a2cae91SOliver-Rainer Wittmann // die korrekte Ersatz-Darstellung erscheint, wenn die
2428a2cae91SOliver-Rainer Wittmann // der neue Link nicht geladen werden konnte.
2438a2cae91SOliver-Rainer Wittmann Graphic aGrf;
2448a2cae91SOliver-Rainer Wittmann aGrf.SetDefaultType();
2458a2cae91SOliver-Rainer Wittmann maGrfObj.SetGraphic( aGrf, rGrfName );
2468a2cae91SOliver-Rainer Wittmann
2478a2cae91SOliver-Rainer Wittmann if ( refLink.Is() )
2488a2cae91SOliver-Rainer Wittmann {
2498a2cae91SOliver-Rainer Wittmann if ( getLayoutFrm( GetDoc()->GetCurrentLayout() ) )
2508a2cae91SOliver-Rainer Wittmann {
2518a2cae91SOliver-Rainer Wittmann SwMsgPoolItem aMsgHint( RES_GRF_REREAD_AND_INCACHE );
2528a2cae91SOliver-Rainer Wittmann ModifyNotification( &aMsgHint, &aMsgHint );
2538a2cae91SOliver-Rainer Wittmann }
254cdf0e10cSrcweir else if ( bNewGrf )
255cdf0e10cSrcweir {
2568a2cae91SOliver-Rainer Wittmann //TODO refLink->setInputStream(getInputStream());
2578a2cae91SOliver-Rainer Wittmann ( (SwBaseLink*) &refLink )->SwapIn();
258cdf0e10cSrcweir }
2598a2cae91SOliver-Rainer Wittmann }
260172c67b2SArmin Le Grand onGraphicChanged();
2618a2cae91SOliver-Rainer Wittmann bSetTwipSize = sal_False;
2628a2cae91SOliver-Rainer Wittmann }
2638a2cae91SOliver-Rainer Wittmann }
2648a2cae91SOliver-Rainer Wittmann else if ( pGraphic && !rGrfName.Len() )
2658a2cae91SOliver-Rainer Wittmann {
2668a2cae91SOliver-Rainer Wittmann // MIB 27.02.2001: Old stream must be deleted before the new one is set.
2678a2cae91SOliver-Rainer Wittmann if ( HasEmbeddedStreamName() )
2688a2cae91SOliver-Rainer Wittmann DelStreamName();
2698a2cae91SOliver-Rainer Wittmann
2708a2cae91SOliver-Rainer Wittmann maGrfObj.SetGraphic( *pGraphic );
271172c67b2SArmin Le Grand onGraphicChanged();
2728a2cae91SOliver-Rainer Wittmann bReadGrf = sal_True;
2738a2cae91SOliver-Rainer Wittmann }
2748a2cae91SOliver-Rainer Wittmann else if ( pGrfObj && !rGrfName.Len() )
2758a2cae91SOliver-Rainer Wittmann {
2768a2cae91SOliver-Rainer Wittmann // MIB 27.02.2001: Old stream must be deleted before the new one is set.
2778a2cae91SOliver-Rainer Wittmann if ( HasEmbeddedStreamName() )
2788a2cae91SOliver-Rainer Wittmann DelStreamName();
2798a2cae91SOliver-Rainer Wittmann
2808a2cae91SOliver-Rainer Wittmann maGrfObj = *pGrfObj;
281172c67b2SArmin Le Grand onGraphicChanged();
2828a2cae91SOliver-Rainer Wittmann if ( pGrfObj->HasUserData() && pGrfObj->IsSwappedOut() )
2838a2cae91SOliver-Rainer Wittmann maGrfObj.SetSwapState();
2848a2cae91SOliver-Rainer Wittmann bReadGrf = sal_True;
2858a2cae91SOliver-Rainer Wittmann }
2868a2cae91SOliver-Rainer Wittmann else if ( !bNewGrf && GRAPHIC_NONE != maGrfObj.GetType() )
2878a2cae91SOliver-Rainer Wittmann return sal_True;
2888a2cae91SOliver-Rainer Wittmann
2898a2cae91SOliver-Rainer Wittmann else
2908a2cae91SOliver-Rainer Wittmann {
2918a2cae91SOliver-Rainer Wittmann if ( HasEmbeddedStreamName() )
2928a2cae91SOliver-Rainer Wittmann DelStreamName();
2938a2cae91SOliver-Rainer Wittmann
2948a2cae91SOliver-Rainer Wittmann // einen neuen Grafik-Link anlegen
2958a2cae91SOliver-Rainer Wittmann InsertLink( rGrfName, rFltName );
2968a2cae91SOliver-Rainer Wittmann
2978a2cae91SOliver-Rainer Wittmann if ( GetNodes().IsDocNodes() )
2988a2cae91SOliver-Rainer Wittmann {
2998a2cae91SOliver-Rainer Wittmann if ( pGraphic )
3008a2cae91SOliver-Rainer Wittmann {
3018a2cae91SOliver-Rainer Wittmann maGrfObj.SetGraphic( *pGraphic, rGrfName );
302172c67b2SArmin Le Grand onGraphicChanged();
3038a2cae91SOliver-Rainer Wittmann bReadGrf = sal_True;
3048a2cae91SOliver-Rainer Wittmann // Verbindung herstellen ohne ein Update; Grafik haben wir!
3058a2cae91SOliver-Rainer Wittmann ( (SwBaseLink*) &refLink )->Connect();
3068a2cae91SOliver-Rainer Wittmann }
3078a2cae91SOliver-Rainer Wittmann else if ( pGrfObj )
3088a2cae91SOliver-Rainer Wittmann {
3098a2cae91SOliver-Rainer Wittmann maGrfObj = *pGrfObj;
3108a2cae91SOliver-Rainer Wittmann maGrfObj.SetLink( rGrfName );
311172c67b2SArmin Le Grand onGraphicChanged();
3128a2cae91SOliver-Rainer Wittmann bReadGrf = sal_True;
3138a2cae91SOliver-Rainer Wittmann // Verbindung herstellen ohne ein Update; Grafik haben wir!
3148a2cae91SOliver-Rainer Wittmann ( (SwBaseLink*) &refLink )->Connect();
3158a2cae91SOliver-Rainer Wittmann }
3168a2cae91SOliver-Rainer Wittmann else
3178a2cae91SOliver-Rainer Wittmann {
3188a2cae91SOliver-Rainer Wittmann Graphic aGrf;
3198a2cae91SOliver-Rainer Wittmann aGrf.SetDefaultType();
3208a2cae91SOliver-Rainer Wittmann maGrfObj.SetGraphic( aGrf, rGrfName );
321172c67b2SArmin Le Grand onGraphicChanged();
322cdf0e10cSrcweir if ( bNewGrf )
323cdf0e10cSrcweir {
3248a2cae91SOliver-Rainer Wittmann ( (SwBaseLink*) &refLink )->SwapIn();
325cdf0e10cSrcweir }
3268a2cae91SOliver-Rainer Wittmann }
3278a2cae91SOliver-Rainer Wittmann }
3288a2cae91SOliver-Rainer Wittmann }
3298a2cae91SOliver-Rainer Wittmann
3308a2cae91SOliver-Rainer Wittmann // Bug 39281: Size nicht sofort loeschen - Events auf ImageMaps
3318a2cae91SOliver-Rainer Wittmann // sollten nicht beim Austauschen nicht ins "leere greifen"
3328a2cae91SOliver-Rainer Wittmann if ( bSetTwipSize )
3338a2cae91SOliver-Rainer Wittmann SetTwipSize( ::GetGraphicSizeTwip( maGrfObj.GetGraphic(), 0 ) );
334cdf0e10cSrcweir
3358a2cae91SOliver-Rainer Wittmann // erzeuge noch einen Update auf die Frames
3368a2cae91SOliver-Rainer Wittmann if ( bReadGrf && bNewGrf )
3378a2cae91SOliver-Rainer Wittmann {
3388a2cae91SOliver-Rainer Wittmann SwMsgPoolItem aMsgHint( RES_UPDATE_ATTR );
3398a2cae91SOliver-Rainer Wittmann ModifyNotification( &aMsgHint, &aMsgHint );
3408a2cae91SOliver-Rainer Wittmann }
3418a2cae91SOliver-Rainer Wittmann
3428a2cae91SOliver-Rainer Wittmann return bReadGrf;
3438a2cae91SOliver-Rainer Wittmann }
344cdf0e10cSrcweir
~SwGrfNode()345cdf0e10cSrcweir SwGrfNode::~SwGrfNode()
346cdf0e10cSrcweir {
347ddde725dSArmin Le Grand delete mpReplacementGraphic;
348ddde725dSArmin Le Grand mpReplacementGraphic = 0;
349ddde725dSArmin Le Grand
350cdf0e10cSrcweir mpThreadConsumer.reset();
3518a2cae91SOliver-Rainer Wittmann
3528a2cae91SOliver-Rainer Wittmann SwDoc* pDoc = GetDoc();
3538a2cae91SOliver-Rainer Wittmann if ( refLink.Is() )
3548a2cae91SOliver-Rainer Wittmann {
3558a2cae91SOliver-Rainer Wittmann ASSERT( !bInSwapIn, "DTOR: stehe noch im SwapIn" );
3568a2cae91SOliver-Rainer Wittmann pDoc->GetLinkManager().Remove( refLink );
3578a2cae91SOliver-Rainer Wittmann refLink->Disconnect();
3588a2cae91SOliver-Rainer Wittmann }
3598a2cae91SOliver-Rainer Wittmann else
3608a2cae91SOliver-Rainer Wittmann {
3618a2cae91SOliver-Rainer Wittmann // #i40014# - A graphic node, which are in linked
362cdf0e10cSrcweir // section, whose link is another section is the document, doesn't
363cdf0e10cSrcweir // have to remove the stream from the storage.
364cdf0e10cSrcweir // Because it's hard to detect this case here and it would only fix
365cdf0e10cSrcweir // one problem with shared graphic files - there are also problems,
366cdf0e10cSrcweir // a certain graphic file is referenced by two independent graphic nodes,
367cdf0e10cSrcweir // brush item or drawing objects, the stream isn't no longer removed here.
368cdf0e10cSrcweir // To do this stuff correct, a reference counting on shared streams
369cdf0e10cSrcweir // inside one document have to be implemented.
370cdf0e10cSrcweir // if( !pDoc->IsInDtor() && HasStreamName() )
371cdf0e10cSrcweir // DelStreamName();
3728a2cae91SOliver-Rainer Wittmann }
3738a2cae91SOliver-Rainer Wittmann //#39289# Die Frames muessen hier bereits geloescht weil der DTor der
3748a2cae91SOliver-Rainer Wittmann //Frms die Grafik noch fuer StopAnimation braucht.
3758a2cae91SOliver-Rainer Wittmann if ( GetDepends() )
3768a2cae91SOliver-Rainer Wittmann DelFrms();
377cdf0e10cSrcweir }
378cdf0e10cSrcweir
379172c67b2SArmin Le Grand /// allow reaction on change of content of GraphicObject
onGraphicChanged()380172c67b2SArmin Le Grand void SwGrfNode::onGraphicChanged()
381172c67b2SArmin Le Grand {
382172c67b2SArmin Le Grand // try to access SwFlyFrmFmt; since title/desc/name are set there, there is no
383172c67b2SArmin Le Grand // use to continue if it is not yet set. If not yet set, call onGraphicChanged()
384172c67b2SArmin Le Grand // when it is set.
3858a2cae91SOliver-Rainer Wittmann SwFlyFrmFmt* pFlyFmt = dynamic_cast< SwFlyFrmFmt* >( GetFlyFmt() );
386172c67b2SArmin Le Grand
3878a2cae91SOliver-Rainer Wittmann if ( pFlyFmt != NULL )
388172c67b2SArmin Le Grand {
3898a2cae91SOliver-Rainer Wittmann const bool bWasSwappedOut = ( GetGrfObj().IsSwappedOut() == sal_True );
3908a2cae91SOliver-Rainer Wittmann
391172c67b2SArmin Le Grand String aName;
392172c67b2SArmin Le Grand String aTitle;
393172c67b2SArmin Le Grand String aDesc;
394172c67b2SArmin Le Grand const SvgDataPtr& rSvgDataPtr = GetGrf().getSvgData();
395172c67b2SArmin Le Grand
3968a2cae91SOliver-Rainer Wittmann if ( rSvgDataPtr.get() )
397172c67b2SArmin Le Grand {
3988a2cae91SOliver-Rainer Wittmann const drawinglayer::primitive2d::Primitive2DSequence aSequence( rSvgDataPtr->getPrimitive2DSequence() );
399172c67b2SArmin Le Grand
4008a2cae91SOliver-Rainer Wittmann if ( aSequence.hasElements() )
401172c67b2SArmin Le Grand {
402172c67b2SArmin Le Grand drawinglayer::geometry::ViewInformation2D aViewInformation2D;
4038a2cae91SOliver-Rainer Wittmann drawinglayer::processor2d::ObjectInfoPrimitiveExtractor2D aProcessor( aViewInformation2D );
404172c67b2SArmin Le Grand
4058a2cae91SOliver-Rainer Wittmann aProcessor.process( aSequence );
406172c67b2SArmin Le Grand
407172c67b2SArmin Le Grand const drawinglayer::primitive2d::ObjectInfoPrimitive2D* pResult = aProcessor.getResult();
408172c67b2SArmin Le Grand
4098a2cae91SOliver-Rainer Wittmann if ( pResult )
410172c67b2SArmin Le Grand {
411172c67b2SArmin Le Grand aName = pResult->getName();
4128a2cae91SOliver-Rainer Wittmann aTitle = pResult->getTitle();
4138a2cae91SOliver-Rainer Wittmann aDesc = pResult->getDesc();
414172c67b2SArmin Le Grand }
415172c67b2SArmin Le Grand }
416172c67b2SArmin Le Grand }
417172c67b2SArmin Le Grand
4188a2cae91SOliver-Rainer Wittmann if ( aTitle.Len() > 0 )
4198a2cae91SOliver-Rainer Wittmann {
4208a2cae91SOliver-Rainer Wittmann SetTitle( aTitle );
4218a2cae91SOliver-Rainer Wittmann }
4228a2cae91SOliver-Rainer Wittmann else if ( aName.Len() > 0 )
4238a2cae91SOliver-Rainer Wittmann {
4248a2cae91SOliver-Rainer Wittmann SetTitle( aName );
4258a2cae91SOliver-Rainer Wittmann }
426172c67b2SArmin Le Grand
4278a2cae91SOliver-Rainer Wittmann if ( aDesc.Len() > 0 )
428172c67b2SArmin Le Grand {
4298a2cae91SOliver-Rainer Wittmann SetDescription( aDesc );
430172c67b2SArmin Le Grand }
431172c67b2SArmin Le Grand
4328a2cae91SOliver-Rainer Wittmann if ( bWasSwappedOut )
433172c67b2SArmin Le Grand {
4348a2cae91SOliver-Rainer Wittmann SwapOut();
435172c67b2SArmin Le Grand }
436172c67b2SArmin Le Grand }
437172c67b2SArmin Le Grand }
438172c67b2SArmin Le Grand
SetGraphic(const Graphic & rGraphic,const String & rLink)4398a2cae91SOliver-Rainer Wittmann void SwGrfNode::SetGraphic(
4408a2cae91SOliver-Rainer Wittmann const Graphic& rGraphic,
4418a2cae91SOliver-Rainer Wittmann const String& rLink )
4428a2cae91SOliver-Rainer Wittmann {
4438a2cae91SOliver-Rainer Wittmann maGrfObj.SetGraphic( rGraphic, rLink );
444172c67b2SArmin Le Grand onGraphicChanged();
445172c67b2SArmin Le Grand }
446cdf0e10cSrcweir
GetReplacementGrfObj() const447ddde725dSArmin Le Grand const GraphicObject* SwGrfNode::GetReplacementGrfObj() const
448ddde725dSArmin Le Grand {
4498a2cae91SOliver-Rainer Wittmann if ( !mpReplacementGraphic )
450ddde725dSArmin Le Grand {
451ddde725dSArmin Le Grand const SvgDataPtr& rSvgDataPtr = GetGrfObj().GetGraphic().getSvgData();
452ddde725dSArmin Le Grand
4538a2cae91SOliver-Rainer Wittmann if ( rSvgDataPtr.get() )
454ddde725dSArmin Le Grand {
4558a2cae91SOliver-Rainer Wittmann const_cast< SwGrfNode* >( this )->mpReplacementGraphic = new GraphicObject( rSvgDataPtr->getReplacement() );
456ddde725dSArmin Le Grand }
457ddde725dSArmin Le Grand }
458ddde725dSArmin Le Grand
459ddde725dSArmin Le Grand return mpReplacementGraphic;
460ddde725dSArmin Le Grand }
461ddde725dSArmin Le Grand
SplitCntntNode(const SwPosition &)4628a2cae91SOliver-Rainer Wittmann SwCntntNode *SwGrfNode::SplitCntntNode(
4638a2cae91SOliver-Rainer Wittmann const SwPosition & )
464cdf0e10cSrcweir {
4658a2cae91SOliver-Rainer Wittmann return this;
466cdf0e10cSrcweir }
467cdf0e10cSrcweir
MakeGrfNode(const SwNodeIndex & rWhere,const String & rGrfName,const String & rFltName,const Graphic * pGraphic,SwGrfFmtColl * pGrfColl,SwAttrSet * pAutoAttr,sal_Bool bDelayed)4688a2cae91SOliver-Rainer Wittmann SwGrfNode * SwNodes::MakeGrfNode(
4698a2cae91SOliver-Rainer Wittmann const SwNodeIndex & rWhere,
4708a2cae91SOliver-Rainer Wittmann const String& rGrfName,
4718a2cae91SOliver-Rainer Wittmann const String& rFltName,
4728a2cae91SOliver-Rainer Wittmann const Graphic* pGraphic,
4738a2cae91SOliver-Rainer Wittmann SwGrfFmtColl* pGrfColl,
4748a2cae91SOliver-Rainer Wittmann SwAttrSet* pAutoAttr,
4758a2cae91SOliver-Rainer Wittmann sal_Bool bDelayed )
476cdf0e10cSrcweir {
4778a2cae91SOliver-Rainer Wittmann ASSERT( pGrfColl, "MakeGrfNode: Formatpointer ist 0." );
4788a2cae91SOliver-Rainer Wittmann SwGrfNode *pNode;
4798a2cae91SOliver-Rainer Wittmann // Delayed erzeugen nur aus dem SW/G-Reader
4808a2cae91SOliver-Rainer Wittmann if ( bDelayed )
4818a2cae91SOliver-Rainer Wittmann pNode = new SwGrfNode( rWhere, rGrfName,
4828a2cae91SOliver-Rainer Wittmann rFltName, pGrfColl, pAutoAttr );
4838a2cae91SOliver-Rainer Wittmann else
4848a2cae91SOliver-Rainer Wittmann pNode = new SwGrfNode( rWhere, rGrfName,
4858a2cae91SOliver-Rainer Wittmann rFltName, pGraphic, pGrfColl, pAutoAttr );
4868a2cae91SOliver-Rainer Wittmann return pNode;
487cdf0e10cSrcweir }
488cdf0e10cSrcweir
MakeGrfNode(const SwNodeIndex & rWhere,const GraphicObject & rGrfObj,SwGrfFmtColl * pGrfColl,SwAttrSet * pAutoAttr)4898a2cae91SOliver-Rainer Wittmann SwGrfNode * SwNodes::MakeGrfNode(
4908a2cae91SOliver-Rainer Wittmann const SwNodeIndex & rWhere,
4918a2cae91SOliver-Rainer Wittmann const GraphicObject& rGrfObj,
4928a2cae91SOliver-Rainer Wittmann SwGrfFmtColl* pGrfColl,
4938a2cae91SOliver-Rainer Wittmann SwAttrSet* pAutoAttr )
494cdf0e10cSrcweir {
4958a2cae91SOliver-Rainer Wittmann ASSERT( pGrfColl, "MakeGrfNode: Formatpointer ist 0." );
4968a2cae91SOliver-Rainer Wittmann return new SwGrfNode( rWhere, rGrfObj, pGrfColl, pAutoAttr );
497cdf0e10cSrcweir }
498cdf0e10cSrcweir
GetTwipSize() const499cdf0e10cSrcweir Size SwGrfNode::GetTwipSize() const
500cdf0e10cSrcweir {
5018a2cae91SOliver-Rainer Wittmann return nGrfSize;
502cdf0e10cSrcweir }
503cdf0e10cSrcweir
ImportGraphic(SvStream & rStrm)5048a2cae91SOliver-Rainer Wittmann sal_Bool SwGrfNode::ImportGraphic(
5058a2cae91SOliver-Rainer Wittmann SvStream& rStrm )
506cdf0e10cSrcweir {
5078a2cae91SOliver-Rainer Wittmann Graphic aGraphic;
5088a2cae91SOliver-Rainer Wittmann const String aURL( maGrfObj.GetUserData() );
5098a2cae91SOliver-Rainer Wittmann
5108a2cae91SOliver-Rainer Wittmann if ( !GraphicFilter::GetGraphicFilter()->ImportGraphic( aGraphic, aURL, rStrm ) )
5118a2cae91SOliver-Rainer Wittmann {
512ddde725dSArmin Le Grand delete mpReplacementGraphic;
513ddde725dSArmin Le Grand mpReplacementGraphic = 0;
5148a2cae91SOliver-Rainer Wittmann
515172c67b2SArmin Le Grand maGrfObj.SetGraphic( aGraphic );
5168a2cae91SOliver-Rainer Wittmann maGrfObj.SetUserData( aURL );
517172c67b2SArmin Le Grand onGraphicChanged();
5188a2cae91SOliver-Rainer Wittmann return sal_True;
5198a2cae91SOliver-Rainer Wittmann }
520cdf0e10cSrcweir
5218a2cae91SOliver-Rainer Wittmann return sal_False;
522cdf0e10cSrcweir }
523cdf0e10cSrcweir
524cdf0e10cSrcweir // Returnwert:
525cdf0e10cSrcweir // -1 : ReRead erfolgreich
526cdf0e10cSrcweir // 0 : nicht geladen
527cdf0e10cSrcweir // 1 : Einlesen erfolgreich
528cdf0e10cSrcweir
SwapIn(sal_Bool bWaitForData)5298a2cae91SOliver-Rainer Wittmann short SwGrfNode::SwapIn(
5308a2cae91SOliver-Rainer Wittmann sal_Bool bWaitForData )
531cdf0e10cSrcweir {
5328a2cae91SOliver-Rainer Wittmann if ( bInSwapIn ) // nicht rekuriv!!
5338a2cae91SOliver-Rainer Wittmann return !maGrfObj.IsSwappedOut();
5348a2cae91SOliver-Rainer Wittmann
5358a2cae91SOliver-Rainer Wittmann short nRet = 0;
5368a2cae91SOliver-Rainer Wittmann bInSwapIn = sal_True;
5378a2cae91SOliver-Rainer Wittmann SwBaseLink* pLink = (SwBaseLink*) (::sfx2::SvBaseLink*) refLink;
5388a2cae91SOliver-Rainer Wittmann
5398a2cae91SOliver-Rainer Wittmann if ( pLink )
5408a2cae91SOliver-Rainer Wittmann {
5418a2cae91SOliver-Rainer Wittmann if ( GRAPHIC_NONE == maGrfObj.GetType() ||
5428a2cae91SOliver-Rainer Wittmann GRAPHIC_DEFAULT == maGrfObj.GetType() )
5438a2cae91SOliver-Rainer Wittmann {
5448a2cae91SOliver-Rainer Wittmann // noch nicht geladener Link
545cdf0e10cSrcweir //TODO pLink->setInputStream(getInputStream());
5468a2cae91SOliver-Rainer Wittmann if ( pLink->SwapIn( bWaitForData ) )
5478a2cae91SOliver-Rainer Wittmann nRet = -1;
5488a2cae91SOliver-Rainer Wittmann else if ( GRAPHIC_DEFAULT == maGrfObj.GetType() )
5498a2cae91SOliver-Rainer Wittmann {
5508a2cae91SOliver-Rainer Wittmann // keine default Bitmap mehr, also neu Painten!
551ddde725dSArmin Le Grand delete mpReplacementGraphic;
552ddde725dSArmin Le Grand mpReplacementGraphic = 0;
553ddde725dSArmin Le Grand
5548a2cae91SOliver-Rainer Wittmann maGrfObj.SetGraphic( Graphic() );
555172c67b2SArmin Le Grand onGraphicChanged();
5568a2cae91SOliver-Rainer Wittmann SwMsgPoolItem aMsgHint( RES_GRAPHIC_PIECE_ARRIVED );
5578a2cae91SOliver-Rainer Wittmann ModifyNotification( &aMsgHint, &aMsgHint );
5588a2cae91SOliver-Rainer Wittmann }
5598a2cae91SOliver-Rainer Wittmann }
5608a2cae91SOliver-Rainer Wittmann else if ( maGrfObj.IsSwappedOut() )
5618a2cae91SOliver-Rainer Wittmann {
5628a2cae91SOliver-Rainer Wittmann // nachzuladender Link
563cdf0e10cSrcweir //TODO pLink->setInputStream(getInputStream());
564cdf0e10cSrcweir nRet = pLink->SwapIn( bWaitForData ) ? 1 : 0;
565cdf0e10cSrcweir }
5668a2cae91SOliver-Rainer Wittmann else
5678a2cae91SOliver-Rainer Wittmann nRet = 1;
5688a2cae91SOliver-Rainer Wittmann }
5690b19465bSOliver-Rainer Wittmann else if ( maGrfObj.IsSwappedOut() )
5700b19465bSOliver-Rainer Wittmann {
5710b19465bSOliver-Rainer Wittmann // Die Grafik ist im Storage oder im TempFile drin
5720b19465bSOliver-Rainer Wittmann if ( !HasEmbeddedStreamName() )
5730b19465bSOliver-Rainer Wittmann nRet = (short) maGrfObj.SwapIn();
5740b19465bSOliver-Rainer Wittmann else
5750b19465bSOliver-Rainer Wittmann {
576cdf0e10cSrcweir
577cdf0e10cSrcweir try
578cdf0e10cSrcweir {
579cdf0e10cSrcweir String aStrmName, aPicStgName;
580cdf0e10cSrcweir _GetStreamStorageNames( aStrmName, aPicStgName );
5818a2cae91SOliver-Rainer Wittmann uno::Reference< embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName );
582cdf0e10cSrcweir SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
583cdf0e10cSrcweir if ( pStrm )
584cdf0e10cSrcweir {
585cdf0e10cSrcweir if ( ImportGraphic( *pStrm ) )
586cdf0e10cSrcweir nRet = 1;
587cdf0e10cSrcweir delete pStrm;
588cdf0e10cSrcweir }
589cdf0e10cSrcweir }
590cdf0e10cSrcweir catch ( uno::Exception& )
591cdf0e10cSrcweir {
592cdf0e10cSrcweir ASSERT( false, "<SwGrfNode::SwapIn(..)> - unhandled exception!" );
593cdf0e10cSrcweir }
5940b19465bSOliver-Rainer Wittmann }
595cdf0e10cSrcweir
5960b19465bSOliver-Rainer Wittmann if ( 1 == nRet )
5970b19465bSOliver-Rainer Wittmann {
5980b19465bSOliver-Rainer Wittmann SwMsgPoolItem aMsg( RES_GRAPHIC_SWAPIN );
599cdf0e10cSrcweir ModifyNotification( &aMsg, &aMsg );
6000b19465bSOliver-Rainer Wittmann }
6010b19465bSOliver-Rainer Wittmann }
6020b19465bSOliver-Rainer Wittmann else
6030b19465bSOliver-Rainer Wittmann nRet = 1;
6040b19465bSOliver-Rainer Wittmann DBG_ASSERTWARNING( nRet, "Grafik kann nicht eingeswapt werden" );
605cdf0e10cSrcweir
6060b19465bSOliver-Rainer Wittmann if ( nRet )
6070b19465bSOliver-Rainer Wittmann {
6080b19465bSOliver-Rainer Wittmann if ( !nGrfSize.Width() && !nGrfSize.Height() )
6090b19465bSOliver-Rainer Wittmann SetTwipSize( ::GetGraphicSizeTwip( maGrfObj.GetGraphic(), 0 ) );
6100b19465bSOliver-Rainer Wittmann }
6110b19465bSOliver-Rainer Wittmann bInSwapIn = sal_False;
6120b19465bSOliver-Rainer Wittmann return nRet;
613cdf0e10cSrcweir }
614cdf0e10cSrcweir
SwapOut()615cdf0e10cSrcweir short SwGrfNode::SwapOut()
616cdf0e10cSrcweir {
6178a2cae91SOliver-Rainer Wittmann if ( maGrfObj.GetType() != GRAPHIC_DEFAULT
6188a2cae91SOliver-Rainer Wittmann && maGrfObj.GetType() != GRAPHIC_NONE
6198a2cae91SOliver-Rainer Wittmann && !maGrfObj.IsSwappedOut()
6208a2cae91SOliver-Rainer Wittmann && !bInSwapIn )
6218a2cae91SOliver-Rainer Wittmann {
6228a2cae91SOliver-Rainer Wittmann if ( !refLink.Is() )
6238a2cae91SOliver-Rainer Wittmann {
6248a2cae91SOliver-Rainer Wittmann // Das Swapping brauchen wir nur fuer Embedded Pictures
6258a2cae91SOliver-Rainer Wittmann // Die Grafik wird in eine TempFile geschrieben, wenn
6268a2cae91SOliver-Rainer Wittmann // sie frisch eingefuegt war, d.h. wenn es noch keinen
6278a2cae91SOliver-Rainer Wittmann // Streamnamen im Storage gibt.
6288a2cae91SOliver-Rainer Wittmann if ( !HasEmbeddedStreamName() )
6298a2cae91SOliver-Rainer Wittmann if ( !maGrfObj.SwapOut() )
6308a2cae91SOliver-Rainer Wittmann return 0;
6318a2cae91SOliver-Rainer Wittmann }
6328a2cae91SOliver-Rainer Wittmann // Geschriebene Grafiken oder Links werden jetzt weggeschmissen
6338a2cae91SOliver-Rainer Wittmann return (short) maGrfObj.SwapOut( NULL );
6348a2cae91SOliver-Rainer Wittmann }
6358a2cae91SOliver-Rainer Wittmann return 1;
636cdf0e10cSrcweir }
637cdf0e10cSrcweir
GetFileFilterNms(String * pFileNm,String * pFilterNm) const6388a2cae91SOliver-Rainer Wittmann sal_Bool SwGrfNode::GetFileFilterNms(
6398a2cae91SOliver-Rainer Wittmann String* pFileNm,
6408a2cae91SOliver-Rainer Wittmann String* pFilterNm ) const
6418a2cae91SOliver-Rainer Wittmann {
6428a2cae91SOliver-Rainer Wittmann sal_Bool bRet = sal_False;
6438a2cae91SOliver-Rainer Wittmann if ( refLink.Is() && refLink->GetLinkManager() )
6448a2cae91SOliver-Rainer Wittmann {
6458a2cae91SOliver-Rainer Wittmann sal_uInt16 nType = refLink->GetObjType();
6468a2cae91SOliver-Rainer Wittmann if ( OBJECT_CLIENT_GRF == nType )
6478a2cae91SOliver-Rainer Wittmann bRet = refLink->GetLinkManager()->GetDisplayNames(
6488a2cae91SOliver-Rainer Wittmann refLink, 0, pFileNm, 0, pFilterNm );
6498a2cae91SOliver-Rainer Wittmann else if ( OBJECT_CLIENT_DDE == nType && pFileNm && pFilterNm )
6508a2cae91SOliver-Rainer Wittmann {
6518a2cae91SOliver-Rainer Wittmann String sApp, sTopic, sItem;
6528a2cae91SOliver-Rainer Wittmann if ( refLink->GetLinkManager()->GetDisplayNames(
6538a2cae91SOliver-Rainer Wittmann refLink, &sApp, &sTopic, &sItem ) )
6548a2cae91SOliver-Rainer Wittmann {
655cdf0e10cSrcweir ( *pFileNm = sApp ) += sfx2::cTokenSeperator;
656cdf0e10cSrcweir ( *pFileNm += sTopic ) += sfx2::cTokenSeperator;
6578a2cae91SOliver-Rainer Wittmann *pFileNm += sItem;
6588a2cae91SOliver-Rainer Wittmann pFilterNm->AssignAscii( RTL_CONSTASCII_STRINGPARAM( "DDE" ) );
6598a2cae91SOliver-Rainer Wittmann bRet = sal_True;
6608a2cae91SOliver-Rainer Wittmann }
6618a2cae91SOliver-Rainer Wittmann }
6628a2cae91SOliver-Rainer Wittmann }
6638a2cae91SOliver-Rainer Wittmann return bRet;
664cdf0e10cSrcweir }
665cdf0e10cSrcweir
666cdf0e10cSrcweir // Eine Grafik Undo-faehig machen. Falls sie sich bereits in
667cdf0e10cSrcweir // einem Storage befindet, muss sie geladen werden.
668cdf0e10cSrcweir
SavePersistentData()669cdf0e10cSrcweir sal_Bool SwGrfNode::SavePersistentData()
670cdf0e10cSrcweir {
6718a2cae91SOliver-Rainer Wittmann if ( refLink.Is() )
6728a2cae91SOliver-Rainer Wittmann {
6738a2cae91SOliver-Rainer Wittmann ASSERT( !bInSwapIn, "SavePersistentData: stehe noch im SwapIn" );
6748a2cae91SOliver-Rainer Wittmann GetDoc()->GetLinkManager().Remove( refLink );
6758a2cae91SOliver-Rainer Wittmann return sal_True;
6768a2cae91SOliver-Rainer Wittmann }
6778a2cae91SOliver-Rainer Wittmann
6788a2cae91SOliver-Rainer Wittmann // Erst mal reinswappen, falls sie im Storage ist
6798a2cae91SOliver-Rainer Wittmann if ( HasEmbeddedStreamName() && !SwapIn() )
6808a2cae91SOliver-Rainer Wittmann return sal_False;
6818a2cae91SOliver-Rainer Wittmann
6828a2cae91SOliver-Rainer Wittmann // #i44367#
683cdf0e10cSrcweir // Do not delete graphic file in storage, because the graphic file could
684cdf0e10cSrcweir // be referenced by other graphic nodes.
685cdf0e10cSrcweir // Because it's hard to detect this case here and it would only fix
686cdf0e10cSrcweir // one problem with shared graphic files - there are also problems,
687cdf0e10cSrcweir // a certain graphic file is referenced by two independent graphic nodes,
688cdf0e10cSrcweir // brush item or drawing objects, the stream isn't no longer removed here.
689cdf0e10cSrcweir // To do this stuff correct, a reference counting on shared streams
690cdf0e10cSrcweir // inside one document have to be implemented.
691cdf0e10cSrcweir // Important note: see also fix for #i40014#
692cdf0e10cSrcweir // if( HasStreamName() )
693cdf0e10cSrcweir // DelStreamName();
694cdf0e10cSrcweir
6958a2cae91SOliver-Rainer Wittmann // Und in TempFile rausswappen
6968a2cae91SOliver-Rainer Wittmann return (sal_Bool) SwapOut();
697cdf0e10cSrcweir }
698cdf0e10cSrcweir
RestorePersistentData()699cdf0e10cSrcweir sal_Bool SwGrfNode::RestorePersistentData()
700cdf0e10cSrcweir {
7018a2cae91SOliver-Rainer Wittmann if ( refLink.Is() )
7028a2cae91SOliver-Rainer Wittmann {
703cdf0e10cSrcweir IDocumentLinksAdministration* pIDLA = getIDocumentLinksAdministration();
704cdf0e10cSrcweir refLink->SetVisible( pIDLA->IsVisibleLinks() );
705cdf0e10cSrcweir pIDLA->GetLinkManager().InsertDDELink( refLink );
7068a2cae91SOliver-Rainer Wittmann if ( getIDocumentLayoutAccess()->GetCurrentLayout() )
7078a2cae91SOliver-Rainer Wittmann refLink->Update();
7088a2cae91SOliver-Rainer Wittmann }
7098a2cae91SOliver-Rainer Wittmann return sal_True;
710cdf0e10cSrcweir }
711cdf0e10cSrcweir
InsertLink(const String & rGrfName,const String & rFltName)7128a2cae91SOliver-Rainer Wittmann void SwGrfNode::InsertLink(
7138a2cae91SOliver-Rainer Wittmann const String& rGrfName,
7148a2cae91SOliver-Rainer Wittmann const String& rFltName )
715cdf0e10cSrcweir {
716cdf0e10cSrcweir refLink = new SwBaseLink( sfx2::LINKUPDATE_ONCALL, FORMAT_GDIMETAFILE, this );
717cdf0e10cSrcweir
718cdf0e10cSrcweir IDocumentLinksAdministration* pIDLA = getIDocumentLinksAdministration();
7198a2cae91SOliver-Rainer Wittmann if ( GetNodes().IsDocNodes() )
7208a2cae91SOliver-Rainer Wittmann {
721cdf0e10cSrcweir refLink->SetVisible( pIDLA->IsVisibleLinks() );
7228a2cae91SOliver-Rainer Wittmann if ( rFltName.EqualsAscii( "DDE" ) )
7238a2cae91SOliver-Rainer Wittmann {
7248a2cae91SOliver-Rainer Wittmann sal_uInt16 nTmp = 0;
7258a2cae91SOliver-Rainer Wittmann String sApp, sTopic, sItem;
726cdf0e10cSrcweir sApp = rGrfName.GetToken( 0, sfx2::cTokenSeperator, nTmp );
727cdf0e10cSrcweir sTopic = rGrfName.GetToken( 0, sfx2::cTokenSeperator, nTmp );
7288a2cae91SOliver-Rainer Wittmann sItem = rGrfName.Copy( nTmp );
729cdf0e10cSrcweir pIDLA->GetLinkManager().InsertDDELink( refLink,
7308a2cae91SOliver-Rainer Wittmann sApp, sTopic, sItem );
7318a2cae91SOliver-Rainer Wittmann }
7328a2cae91SOliver-Rainer Wittmann else
7338a2cae91SOliver-Rainer Wittmann {
7348a2cae91SOliver-Rainer Wittmann sal_Bool bSync = rFltName.EqualsAscii( "SYNCHRON" );
7358a2cae91SOliver-Rainer Wittmann refLink->SetSynchron( bSync );
736cdf0e10cSrcweir refLink->SetContentType( SOT_FORMATSTR_ID_SVXB );
737cdf0e10cSrcweir
738cdf0e10cSrcweir pIDLA->GetLinkManager().InsertFileLink( *refLink,
7398a2cae91SOliver-Rainer Wittmann OBJECT_CLIENT_GRF, rGrfName,
7408a2cae91SOliver-Rainer Wittmann ( !bSync && rFltName.Len() ? &rFltName : 0 ) );
7418a2cae91SOliver-Rainer Wittmann }
7428a2cae91SOliver-Rainer Wittmann }
7438a2cae91SOliver-Rainer Wittmann maGrfObj.SetLink( rGrfName );
744cdf0e10cSrcweir }
745cdf0e10cSrcweir
ReleaseLink()746cdf0e10cSrcweir void SwGrfNode::ReleaseLink()
747cdf0e10cSrcweir {
7488a2cae91SOliver-Rainer Wittmann if ( refLink.Is() )
749c37c1899SArmin Le Grand {
7508a2cae91SOliver-Rainer Wittmann const String aFileName( maGrfObj.GetLink() );
7518a2cae91SOliver-Rainer Wittmann const Graphic aLocalGraphic( maGrfObj.GetGraphic() );
7528a2cae91SOliver-Rainer Wittmann const bool bHasOriginalData( aLocalGraphic.IsLink() );
753c37c1899SArmin Le Grand
754c37c1899SArmin Le Grand {
755c37c1899SArmin Le Grand bInSwapIn = sal_True;
7568a2cae91SOliver-Rainer Wittmann SwBaseLink* pLink = (SwBaseLink*) (::sfx2::SvBaseLink*) refLink;
757cdf0e10cSrcweir //TODO pLink->setInputStream(getInputStream());
758c37c1899SArmin Le Grand pLink->SwapIn( sal_True, sal_True );
759c37c1899SArmin Le Grand bInSwapIn = sal_False;
760c37c1899SArmin Le Grand }
761c37c1899SArmin Le Grand
762cdf0e10cSrcweir getIDocumentLinksAdministration()->GetLinkManager().Remove( refLink );
763c37c1899SArmin Le Grand refLink.Clear();
764c37c1899SArmin Le Grand maGrfObj.SetLink();
765c37c1899SArmin Le Grand
766c37c1899SArmin Le Grand // #15508# added extra processing after getting rid of the link. Use whatever is
767c37c1899SArmin Le Grand // known from the formally linked graphic to get to a state as close to a directly
768c37c1899SArmin Le Grand // unlinked insterted graphic as possible. Goal is to have a valid GfxLink at the
769c37c1899SArmin Le Grand // ImplGraphic (see there) that holds temporary data to the original data and type
770c37c1899SArmin Le Grand // information about the original data. Only when this is given will
771c37c1899SArmin Le Grand // SvXMLGraphicHelper::ImplInsertGraphicURL which is used at export use that type
772c37c1899SArmin Le Grand // and use the original graphic at export for the ODF, without evtl. recoding
773c37c1899SArmin Le Grand // of trhe bitmap graphic data to something without loss (e.g. PNG) but bigger
7748a2cae91SOliver-Rainer Wittmann if ( bHasOriginalData )
775c37c1899SArmin Le Grand {
776c37c1899SArmin Le Grand // #15508# if we have the original data at the Graphic, let it survive
777c37c1899SArmin Le Grand // by using that Graphic again, this time at a GraphicObject without link.
778c37c1899SArmin Le Grand // This happens e.g. when inserting a linked graphic and breaking the link
7798a2cae91SOliver-Rainer Wittmann maGrfObj.SetGraphic( aLocalGraphic );
780c37c1899SArmin Le Grand }
7818a2cae91SOliver-Rainer Wittmann else if ( aFileName.Len() )
782c37c1899SArmin Le Grand {
783c37c1899SArmin Le Grand // #15508# we have no original data, but a file name. This happens e.g.
784c37c1899SArmin Le Grand // when inserting a linked graphic and save, reload document. Try to access
785c37c1899SArmin Le Grand // that data from the original file; if this works, use it. Else use the
786c37c1899SArmin Le Grand // data we have (but without knowing the original format)
787c37c1899SArmin Le Grand int nRes = GRFILTER_OK;
788c37c1899SArmin Le Grand GraphicFilter* pFlt = GraphicFilter::GetGraphicFilter();
789c37c1899SArmin Le Grand Graphic aNew;
7908a2cae91SOliver-Rainer Wittmann nRes = GraphicFilter::LoadGraphic( aFileName, String(), aNew, pFlt );
791c37c1899SArmin Le Grand
7928a2cae91SOliver-Rainer Wittmann if ( GRFILTER_OK == nRes )
793c37c1899SArmin Le Grand {
7948a2cae91SOliver-Rainer Wittmann maGrfObj.SetGraphic( aNew );
795c37c1899SArmin Le Grand }
796c37c1899SArmin Le Grand }
797c37c1899SArmin Le Grand }
798cdf0e10cSrcweir }
799cdf0e10cSrcweir
SetTwipSize(const Size & rSz)8008a2cae91SOliver-Rainer Wittmann void SwGrfNode::SetTwipSize(
8018a2cae91SOliver-Rainer Wittmann const Size& rSz )
802cdf0e10cSrcweir {
8038a2cae91SOliver-Rainer Wittmann nGrfSize = rSz;
8048a2cae91SOliver-Rainer Wittmann if ( IsScaleImageMap() && nGrfSize.Width() && nGrfSize.Height() )
8058a2cae91SOliver-Rainer Wittmann {
8068a2cae91SOliver-Rainer Wittmann // Image-Map an Grafik-Groesse anpassen
8078a2cae91SOliver-Rainer Wittmann ScaleImageMap();
8088a2cae91SOliver-Rainer Wittmann
8098a2cae91SOliver-Rainer Wittmann // Image-Map nicht noch einmal skalieren
8108a2cae91SOliver-Rainer Wittmann SetScaleImageMap( sal_False );
8118a2cae91SOliver-Rainer Wittmann }
812cdf0e10cSrcweir }
813cdf0e10cSrcweir
ScaleImageMap()814cdf0e10cSrcweir void SwGrfNode::ScaleImageMap()
815cdf0e10cSrcweir {
8168a2cae91SOliver-Rainer Wittmann if ( !nGrfSize.Width() || !nGrfSize.Height() )
8178a2cae91SOliver-Rainer Wittmann return;
818cdf0e10cSrcweir
8198a2cae91SOliver-Rainer Wittmann // dann die Image-Map skalieren
8208a2cae91SOliver-Rainer Wittmann SwFrmFmt* pFmt = GetFlyFmt();
821cdf0e10cSrcweir
8228a2cae91SOliver-Rainer Wittmann if ( !pFmt )
8238a2cae91SOliver-Rainer Wittmann return;
824cdf0e10cSrcweir
8258a2cae91SOliver-Rainer Wittmann SwFmtURL aURL( pFmt->GetURL() );
8268a2cae91SOliver-Rainer Wittmann if ( !aURL.GetMap() )
8278a2cae91SOliver-Rainer Wittmann return;
828cdf0e10cSrcweir
8298a2cae91SOliver-Rainer Wittmann sal_Bool bScale = sal_False;
8308a2cae91SOliver-Rainer Wittmann Fraction aScaleX( 1, 1 );
8318a2cae91SOliver-Rainer Wittmann Fraction aScaleY( 1, 1 );
832cdf0e10cSrcweir
8338a2cae91SOliver-Rainer Wittmann const SwFmtFrmSize& rFrmSize = pFmt->GetFrmSize();
8348a2cae91SOliver-Rainer Wittmann const SvxBoxItem& rBox = pFmt->GetBox();
835cdf0e10cSrcweir
8368a2cae91SOliver-Rainer Wittmann if ( !rFrmSize.GetWidthPercent() )
8378a2cae91SOliver-Rainer Wittmann {
8388a2cae91SOliver-Rainer Wittmann SwTwips nWidth = rFrmSize.GetWidth();
839cdf0e10cSrcweir
8408a2cae91SOliver-Rainer Wittmann nWidth -= rBox.CalcLineSpace( BOX_LINE_LEFT ) +
8418a2cae91SOliver-Rainer Wittmann rBox.CalcLineSpace( BOX_LINE_RIGHT );
842cdf0e10cSrcweir
8438a2cae91SOliver-Rainer Wittmann ASSERT( nWidth>0, "Gibt es 0 twip breite Grafiken!?" );
844cdf0e10cSrcweir
8458a2cae91SOliver-Rainer Wittmann if ( nGrfSize.Width() != nWidth )
8468a2cae91SOliver-Rainer Wittmann {
8478a2cae91SOliver-Rainer Wittmann aScaleX = Fraction( nGrfSize.Width(), nWidth );
8488a2cae91SOliver-Rainer Wittmann bScale = sal_True;
8498a2cae91SOliver-Rainer Wittmann }
8508a2cae91SOliver-Rainer Wittmann }
8518a2cae91SOliver-Rainer Wittmann if ( !rFrmSize.GetHeightPercent() )
8528a2cae91SOliver-Rainer Wittmann {
8538a2cae91SOliver-Rainer Wittmann SwTwips nHeight = rFrmSize.GetHeight();
854cdf0e10cSrcweir
8558a2cae91SOliver-Rainer Wittmann nHeight -= rBox.CalcLineSpace( BOX_LINE_TOP ) +
8568a2cae91SOliver-Rainer Wittmann rBox.CalcLineSpace( BOX_LINE_BOTTOM );
857cdf0e10cSrcweir
8588a2cae91SOliver-Rainer Wittmann ASSERT( nHeight>0, "Gibt es 0 twip hohe Grafiken!?" );
859cdf0e10cSrcweir
8608a2cae91SOliver-Rainer Wittmann if ( nGrfSize.Height() != nHeight )
8618a2cae91SOliver-Rainer Wittmann {
8628a2cae91SOliver-Rainer Wittmann aScaleY = Fraction( nGrfSize.Height(), nHeight );
8638a2cae91SOliver-Rainer Wittmann bScale = sal_True;
8648a2cae91SOliver-Rainer Wittmann }
8658a2cae91SOliver-Rainer Wittmann }
866cdf0e10cSrcweir
8678a2cae91SOliver-Rainer Wittmann if ( bScale )
8688a2cae91SOliver-Rainer Wittmann {
8698a2cae91SOliver-Rainer Wittmann aURL.GetMap()->Scale( aScaleX, aScaleY );
870cdf0e10cSrcweir pFmt->SetFmtAttr( aURL );
8718a2cae91SOliver-Rainer Wittmann }
872cdf0e10cSrcweir }
873cdf0e10cSrcweir
DelStreamName()874cdf0e10cSrcweir void SwGrfNode::DelStreamName()
875cdf0e10cSrcweir {
8768a2cae91SOliver-Rainer Wittmann if ( HasEmbeddedStreamName() )
8778a2cae91SOliver-Rainer Wittmann {
8788a2cae91SOliver-Rainer Wittmann // Dann die Grafik im Storage loeschen
8798a2cae91SOliver-Rainer Wittmann uno::Reference< embed::XStorage > xDocStg = GetDoc()->GetDocStorage();
8808a2cae91SOliver-Rainer Wittmann if ( xDocStg.is() )
8818a2cae91SOliver-Rainer Wittmann {
882cdf0e10cSrcweir try
883cdf0e10cSrcweir {
884cdf0e10cSrcweir String aPicStgName, aStrmName;
885cdf0e10cSrcweir _GetStreamStorageNames( aStrmName, aPicStgName );
8868a2cae91SOliver-Rainer Wittmann uno::Reference< embed::XStorage > refPics = xDocStg;
887cdf0e10cSrcweir if ( aPicStgName.Len() )
888cdf0e10cSrcweir refPics = xDocStg->openStorageElement( aPicStgName, embed::ElementModes::READWRITE );
889cdf0e10cSrcweir refPics->removeElement( aStrmName );
8908a2cae91SOliver-Rainer Wittmann uno::Reference< embed::XTransactedObject > xTrans( refPics, uno::UNO_QUERY );
891cdf0e10cSrcweir if ( xTrans.is() )
892cdf0e10cSrcweir xTrans->commit();
893cdf0e10cSrcweir }
894cdf0e10cSrcweir catch ( uno::Exception& )
895cdf0e10cSrcweir {
896cdf0e10cSrcweir // --> OD 2005-04-25 #i48434#
897cdf0e10cSrcweir ASSERT( false, "<SwGrfNode::DelStreamName()> - unhandled exception!" );
898cdf0e10cSrcweir // <--
899cdf0e10cSrcweir }
9008a2cae91SOliver-Rainer Wittmann }
901cdf0e10cSrcweir
9028a2cae91SOliver-Rainer Wittmann maGrfObj.SetUserData();
9038a2cae91SOliver-Rainer Wittmann }
904cdf0e10cSrcweir }
905cdf0e10cSrcweir
906cdf0e10cSrcweir /** helper method to get a substorage of the document storage for readonly access.
907cdf0e10cSrcweir
9088a2cae91SOliver-Rainer Wittmann #i53025#
9098a2cae91SOliver-Rainer Wittmann A substorage with the specified name will be opened readonly. If the provided
9108a2cae91SOliver-Rainer Wittmann name is empty the root storage will be returned.
9118a2cae91SOliver-Rainer Wittmann */
_GetDocSubstorageOrRoot(const String & aStgName) const9128a2cae91SOliver-Rainer Wittmann uno::Reference< embed::XStorage > SwGrfNode::_GetDocSubstorageOrRoot(
9138a2cae91SOliver-Rainer Wittmann const String& aStgName ) const
9148a2cae91SOliver-Rainer Wittmann {
9158a2cae91SOliver-Rainer Wittmann uno::Reference< embed::XStorage > refStor =
9168a2cae91SOliver-Rainer Wittmann const_cast< SwGrfNode* >( this )->GetDoc()->GetDocStorage();
917cdf0e10cSrcweir ASSERT( refStor.is(), "Kein Storage am Doc" );
918cdf0e10cSrcweir
919cdf0e10cSrcweir if ( aStgName.Len() )
920cdf0e10cSrcweir {
9218a2cae91SOliver-Rainer Wittmann if ( refStor.is() )
922cdf0e10cSrcweir return refStor->openStorageElement( aStgName, embed::ElementModes::READ );
923cdf0e10cSrcweir }
924cdf0e10cSrcweir
925cdf0e10cSrcweir return refStor;
926cdf0e10cSrcweir }
927cdf0e10cSrcweir
928cdf0e10cSrcweir /** helper method to determine stream for the embedded graphic.
929cdf0e10cSrcweir
9308a2cae91SOliver-Rainer Wittmann #i48434#
9318a2cae91SOliver-Rainer Wittmann Important note: caller of this method has to handle the thrown exceptions
9328a2cae91SOliver-Rainer Wittmann #i53025#
9338a2cae91SOliver-Rainer Wittmann Storage, which should contain the stream of the embedded graphic, is
9348a2cae91SOliver-Rainer Wittmann provided via parameter. Otherwise the returned stream will be closed
9358a2cae91SOliver-Rainer Wittmann after the the method returns, because its parent stream is closed and deleted.
9368a2cae91SOliver-Rainer Wittmann Proposed name of embedded graphic stream is also provided by parameter.
937cdf0e10cSrcweir
9388a2cae91SOliver-Rainer Wittmann @author OD
9398a2cae91SOliver-Rainer Wittmann */
_GetStreamForEmbedGrf(const uno::Reference<embed::XStorage> & _refPics,String & _aStrmName) const940cdf0e10cSrcweir SvStream* SwGrfNode::_GetStreamForEmbedGrf(
9418a2cae91SOliver-Rainer Wittmann const uno::Reference< embed::XStorage >& _refPics,
9428a2cae91SOliver-Rainer Wittmann String& _aStrmName ) const
9438a2cae91SOliver-Rainer Wittmann {
944cdf0e10cSrcweir SvStream* pStrm( 0L );
945cdf0e10cSrcweir
9468a2cae91SOliver-Rainer Wittmann if ( _refPics.is() && _aStrmName.Len() )
947cdf0e10cSrcweir {
948cdf0e10cSrcweir // If stream doesn't exist in the storage, try access the graphic file by
949cdf0e10cSrcweir // re-generating its name.
950cdf0e10cSrcweir // A save action can have changed the filename of the embedded graphic,
951cdf0e10cSrcweir // because a changed unique ID of the graphic is calculated.
9528a2cae91SOliver-Rainer Wittmann // #b6364738#
953cdf0e10cSrcweir // recursive calls of <GetUniqueID()> have to be avoided.
954cdf0e10cSrcweir // Thus, use local static boolean to assure this.
955cdf0e10cSrcweir static bool bInRegenerateStrmName( false );
956cdf0e10cSrcweir if ( !bInRegenerateStrmName &&
957cdf0e10cSrcweir ( !_refPics->hasByName( _aStrmName ) ||
958cdf0e10cSrcweir !_refPics->isStreamElement( _aStrmName ) ) )
959cdf0e10cSrcweir {
960cdf0e10cSrcweir bInRegenerateStrmName = true;
961cdf0e10cSrcweir xub_StrLen nExtPos = _aStrmName.Search( '.' );
962cdf0e10cSrcweir String aExtStr = _aStrmName.Copy( nExtPos );
9638a2cae91SOliver-Rainer Wittmann Graphic aGraphic( GetGrfObj().GetGraphic() );
9648a2cae91SOliver-Rainer Wittmann if ( aGraphic.GetType() != GRAPHIC_NONE )
9658a2cae91SOliver-Rainer Wittmann {
9668a2cae91SOliver-Rainer Wittmann _aStrmName = String( GetGrfObj().GetUniqueID(), RTL_TEXTENCODING_ASCII_US );
9678a2cae91SOliver-Rainer Wittmann _aStrmName += aExtStr;
9688a2cae91SOliver-Rainer Wittmann }
969cdf0e10cSrcweir bInRegenerateStrmName = false;
970cdf0e10cSrcweir }
971cdf0e10cSrcweir
972cdf0e10cSrcweir // assure that graphic file exist in the storage.
973cdf0e10cSrcweir if ( _refPics->hasByName( _aStrmName ) &&
974cdf0e10cSrcweir _refPics->isStreamElement( _aStrmName ) )
975cdf0e10cSrcweir {
9768a2cae91SOliver-Rainer Wittmann uno::Reference< io::XStream > refStrm = _refPics->openStreamElement( _aStrmName, embed::ElementModes::READ );
977cdf0e10cSrcweir pStrm = utl::UcbStreamHelper::CreateStream( refStrm );
978cdf0e10cSrcweir }
979cdf0e10cSrcweir else
980cdf0e10cSrcweir {
981cdf0e10cSrcweir ASSERT( false, "<SwGrfNode::_GetStreamForEmbedGrf(..)> - embedded graphic file not found!" );
982cdf0e10cSrcweir }
983cdf0e10cSrcweir }
984cdf0e10cSrcweir
985cdf0e10cSrcweir return pStrm;
986cdf0e10cSrcweir }
987cdf0e10cSrcweir
988cdf0e10cSrcweir
_GetStreamStorageNames(String & rStrmName,String & rStorName) const9898a2cae91SOliver-Rainer Wittmann void SwGrfNode::_GetStreamStorageNames(
9908a2cae91SOliver-Rainer Wittmann String& rStrmName,
9918a2cae91SOliver-Rainer Wittmann String& rStorName ) const
9928a2cae91SOliver-Rainer Wittmann {
9938a2cae91SOliver-Rainer Wittmann rStorName.Erase();
9948a2cae91SOliver-Rainer Wittmann rStrmName.Erase();
995cdf0e10cSrcweir
9968a2cae91SOliver-Rainer Wittmann String aUserData( maGrfObj.GetUserData() );
9978a2cae91SOliver-Rainer Wittmann if ( !aUserData.Len() )
998cdf0e10cSrcweir return;
999cdf0e10cSrcweir
10008a2cae91SOliver-Rainer Wittmann String aProt( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.Package:" ) );
10018a2cae91SOliver-Rainer Wittmann if ( 0 == aUserData.CompareTo( aProt, aProt.Len() ) )
10028a2cae91SOliver-Rainer Wittmann {
10038a2cae91SOliver-Rainer Wittmann // 6.0 (XML) Package
10048a2cae91SOliver-Rainer Wittmann xub_StrLen nPos = aUserData.Search( '/' );
10058a2cae91SOliver-Rainer Wittmann if ( STRING_NOTFOUND == nPos )
10068a2cae91SOliver-Rainer Wittmann {
10078a2cae91SOliver-Rainer Wittmann rStrmName = aUserData.Copy( aProt.Len() );
10088a2cae91SOliver-Rainer Wittmann }
10098a2cae91SOliver-Rainer Wittmann else
10108a2cae91SOliver-Rainer Wittmann {
10118a2cae91SOliver-Rainer Wittmann xub_StrLen nPathStart = aProt.Len();
10128a2cae91SOliver-Rainer Wittmann if ( 0 == aUserData.CompareToAscii( "./", 2 ) )
10138a2cae91SOliver-Rainer Wittmann nPathStart += 2;
10148a2cae91SOliver-Rainer Wittmann rStorName = aUserData.Copy( nPathStart, nPos - nPathStart );
10158a2cae91SOliver-Rainer Wittmann rStrmName = aUserData.Copy( nPos + 1 );
10168a2cae91SOliver-Rainer Wittmann }
10178a2cae91SOliver-Rainer Wittmann }
1018cdf0e10cSrcweir else
1019cdf0e10cSrcweir {
1020cdf0e10cSrcweir ASSERT( false,
10218a2cae91SOliver-Rainer Wittmann "<SwGrfNode::_GetStreamStorageNames(..)> - unknown graphic URL type. Code for handling 3.1 - 5.2 storages has been deleted by issue i53025." );
1022cdf0e10cSrcweir }
10238a2cae91SOliver-Rainer Wittmann ASSERT( STRING_NOTFOUND == rStrmName.Search( '/' ),
10248a2cae91SOliver-Rainer Wittmann "invalid graphic stream name" );
1025cdf0e10cSrcweir }
1026cdf0e10cSrcweir
10278a2cae91SOliver-Rainer Wittmann
MakeCopy(SwDoc * pDoc,const SwNodeIndex & rIdx) const10288a2cae91SOliver-Rainer Wittmann SwCntntNode* SwGrfNode::MakeCopy(
10298a2cae91SOliver-Rainer Wittmann SwDoc* pDoc,
10308a2cae91SOliver-Rainer Wittmann const SwNodeIndex& rIdx ) const
10318a2cae91SOliver-Rainer Wittmann {
10328a2cae91SOliver-Rainer Wittmann // kopiere die Formate in das andere Dokument:
10338a2cae91SOliver-Rainer Wittmann SwGrfFmtColl* pColl = pDoc->CopyGrfColl( *GetGrfColl() );
10348a2cae91SOliver-Rainer Wittmann
10358a2cae91SOliver-Rainer Wittmann Graphic aTmpGrf;
10368a2cae91SOliver-Rainer Wittmann SwBaseLink* pLink = (SwBaseLink*) (::sfx2::SvBaseLink*) refLink;
10378a2cae91SOliver-Rainer Wittmann if ( !pLink && HasEmbeddedStreamName() )
10388a2cae91SOliver-Rainer Wittmann {
1039cdf0e10cSrcweir try
1040cdf0e10cSrcweir {
1041cdf0e10cSrcweir String aStrmName, aPicStgName;
1042cdf0e10cSrcweir _GetStreamStorageNames( aStrmName, aPicStgName );
10438a2cae91SOliver-Rainer Wittmann uno::Reference< embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName );
1044cdf0e10cSrcweir SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
1045cdf0e10cSrcweir if ( pStrm )
1046cdf0e10cSrcweir {
10478a2cae91SOliver-Rainer Wittmann const String aURL( maGrfObj.GetUserData() );
10488a2cae91SOliver-Rainer Wittmann GraphicFilter::GetGraphicFilter()->ImportGraphic( aTmpGrf, aURL, *pStrm );
1049cdf0e10cSrcweir delete pStrm;
1050cdf0e10cSrcweir }
1051cdf0e10cSrcweir }
1052cdf0e10cSrcweir catch ( uno::Exception& )
1053cdf0e10cSrcweir {
1054cdf0e10cSrcweir ASSERT( false, "<SwGrfNode::MakeCopy(..)> - unhandled exception!" );
1055cdf0e10cSrcweir }
10568a2cae91SOliver-Rainer Wittmann }
10578a2cae91SOliver-Rainer Wittmann else
10588a2cae91SOliver-Rainer Wittmann {
10598a2cae91SOliver-Rainer Wittmann if ( maGrfObj.IsSwappedOut() )
10608a2cae91SOliver-Rainer Wittmann const_cast< SwGrfNode* >( this )->SwapIn();
10618a2cae91SOliver-Rainer Wittmann aTmpGrf = maGrfObj.GetGraphic();
10628a2cae91SOliver-Rainer Wittmann }
1063cdf0e10cSrcweir
1064cdf0e10cSrcweir const sfx2::LinkManager& rMgr = getIDocumentLinksAdministration()->GetLinkManager();
10658a2cae91SOliver-Rainer Wittmann String sFile, sFilter;
10668a2cae91SOliver-Rainer Wittmann if ( IsLinkedFile() )
10678a2cae91SOliver-Rainer Wittmann rMgr.GetDisplayNames( refLink, 0, &sFile, 0, &sFilter );
10688a2cae91SOliver-Rainer Wittmann else if ( IsLinkedDDE() )
10698a2cae91SOliver-Rainer Wittmann {
10708a2cae91SOliver-Rainer Wittmann String sTmp1, sTmp2;
10718a2cae91SOliver-Rainer Wittmann rMgr.GetDisplayNames( refLink, &sTmp1, &sTmp2, &sFilter );
1072cdf0e10cSrcweir sfx2::MakeLnkName( sFile, &sTmp1, sTmp2, sFilter );
10738a2cae91SOliver-Rainer Wittmann sFilter.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "DDE" ) );
10748a2cae91SOliver-Rainer Wittmann }
1075cdf0e10cSrcweir
10768a2cae91SOliver-Rainer Wittmann SwGrfNode* pGrfNd = pDoc->GetNodes().MakeGrfNode( rIdx, sFile, sFilter,
10778a2cae91SOliver-Rainer Wittmann &aTmpGrf, pColl,
10788a2cae91SOliver-Rainer Wittmann (SwAttrSet*) GetpSwAttrSet() );
1079cdf0e10cSrcweir pGrfNd->SetTitle( GetTitle() );
1080cdf0e10cSrcweir pGrfNd->SetDescription( GetDescription() );
1081cdf0e10cSrcweir pGrfNd->SetContour( HasContour(), HasAutomaticContour() );
10828a2cae91SOliver-Rainer Wittmann return pGrfNd;
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir
IMPL_LINK(SwGrfNode,SwapGraphic,GraphicObject *,pGrfObj)1085cdf0e10cSrcweir IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj )
1086cdf0e10cSrcweir {
10878a2cae91SOliver-Rainer Wittmann SvStream* pRet;
10888a2cae91SOliver-Rainer Wittmann
10898a2cae91SOliver-Rainer Wittmann // #101174#: Keep graphic while in swap in. That's at least important
10908a2cae91SOliver-Rainer Wittmann // when breaking links, because in this situation a reschedule call and
10918a2cae91SOliver-Rainer Wittmann // a DataChanged call lead to a paint of the graphic.
10928a2cae91SOliver-Rainer Wittmann if ( pGrfObj->IsInSwapOut() && ( IsSelected() || bInSwapIn ) )
10938a2cae91SOliver-Rainer Wittmann pRet = GRFMGR_AUTOSWAPSTREAM_NONE;
10948a2cae91SOliver-Rainer Wittmann else if ( refLink.Is() )
10958a2cae91SOliver-Rainer Wittmann {
10968a2cae91SOliver-Rainer Wittmann if ( pGrfObj->IsInSwapIn() )
10978a2cae91SOliver-Rainer Wittmann {
10988a2cae91SOliver-Rainer Wittmann // then make it by your self
10998a2cae91SOliver-Rainer Wittmann if ( !bInSwapIn )
11008a2cae91SOliver-Rainer Wittmann {
11018a2cae91SOliver-Rainer Wittmann sal_Bool bIsModifyLocked = IsModifyLocked();
11028a2cae91SOliver-Rainer Wittmann LockModify();
11038a2cae91SOliver-Rainer Wittmann SwapIn( sal_False );
11048a2cae91SOliver-Rainer Wittmann if ( !bIsModifyLocked )
11058a2cae91SOliver-Rainer Wittmann UnlockModify();
11068a2cae91SOliver-Rainer Wittmann }
11078a2cae91SOliver-Rainer Wittmann pRet = GRFMGR_AUTOSWAPSTREAM_NONE;
11088a2cae91SOliver-Rainer Wittmann }
11098a2cae91SOliver-Rainer Wittmann else
11108a2cae91SOliver-Rainer Wittmann pRet = GRFMGR_AUTOSWAPSTREAM_LINK;
11118a2cae91SOliver-Rainer Wittmann }
11128a2cae91SOliver-Rainer Wittmann else
11138a2cae91SOliver-Rainer Wittmann {
11148a2cae91SOliver-Rainer Wittmann pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
11158a2cae91SOliver-Rainer Wittmann
11168a2cae91SOliver-Rainer Wittmann if ( HasEmbeddedStreamName() )
11178a2cae91SOliver-Rainer Wittmann {
1118cdf0e10cSrcweir try
1119cdf0e10cSrcweir {
1120cdf0e10cSrcweir String aStrmName, aPicStgName;
1121cdf0e10cSrcweir _GetStreamStorageNames( aStrmName, aPicStgName );
11228a2cae91SOliver-Rainer Wittmann uno::Reference< embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName );
1123cdf0e10cSrcweir SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
1124cdf0e10cSrcweir if ( pStrm )
1125cdf0e10cSrcweir {
11268a2cae91SOliver-Rainer Wittmann if ( pGrfObj->IsInSwapOut() )
1127cdf0e10cSrcweir {
1128cdf0e10cSrcweir pRet = GRFMGR_AUTOSWAPSTREAM_LINK;
1129cdf0e10cSrcweir }
1130cdf0e10cSrcweir else
1131cdf0e10cSrcweir {
1132cdf0e10cSrcweir ImportGraphic( *pStrm );
1133cdf0e10cSrcweir pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
1134cdf0e10cSrcweir }
1135cdf0e10cSrcweir delete pStrm;
1136cdf0e10cSrcweir }
1137cdf0e10cSrcweir }
1138cdf0e10cSrcweir catch ( uno::Exception& )
1139cdf0e10cSrcweir {
1140cdf0e10cSrcweir ASSERT( false, "<SwapGraphic> - unhandled exception!" );
1141cdf0e10cSrcweir }
11428a2cae91SOliver-Rainer Wittmann }
11438a2cae91SOliver-Rainer Wittmann }
1144cdf0e10cSrcweir
11458a2cae91SOliver-Rainer Wittmann return (long) pRet;
1146cdf0e10cSrcweir }
1147cdf0e10cSrcweir
1148cdf0e10cSrcweir // alle QuickDraw-Bitmaps eines speziellen Docs loeschen
DelAllGrfCacheEntries(SwDoc * pDoc)11498a2cae91SOliver-Rainer Wittmann void DelAllGrfCacheEntries(
11508a2cae91SOliver-Rainer Wittmann SwDoc* pDoc )
1151cdf0e10cSrcweir {
11528a2cae91SOliver-Rainer Wittmann if ( pDoc )
11538a2cae91SOliver-Rainer Wittmann {
11548a2cae91SOliver-Rainer Wittmann // alle Graphic-Links mit dem Namen aus dem Cache loeschen
11558a2cae91SOliver-Rainer Wittmann const sfx2::LinkManager& rLnkMgr = pDoc->GetLinkManager();
1156cdf0e10cSrcweir const ::sfx2::SvBaseLinks& rLnks = rLnkMgr.GetLinks();
11578a2cae91SOliver-Rainer Wittmann SwGrfNode* pGrfNd;
11588a2cae91SOliver-Rainer Wittmann String sFileNm;
11598a2cae91SOliver-Rainer Wittmann for ( sal_uInt16 n = rLnks.Count(); n; )
11608a2cae91SOliver-Rainer Wittmann {
11618a2cae91SOliver-Rainer Wittmann ::sfx2::SvBaseLink* pLnk = &( *rLnks[--n] );
11628a2cae91SOliver-Rainer Wittmann if ( pLnk && OBJECT_CLIENT_GRF == pLnk->GetObjType()
11638a2cae91SOliver-Rainer Wittmann && rLnkMgr.GetDisplayNames( pLnk, 0, &sFileNm )
11648a2cae91SOliver-Rainer Wittmann && pLnk->ISA( SwBaseLink )
11658a2cae91SOliver-Rainer Wittmann && 0 != ( pGrfNd = ( (SwBaseLink*) pLnk )->GetCntntNode()->GetGrfNode() ) )
11668a2cae91SOliver-Rainer Wittmann {
11678a2cae91SOliver-Rainer Wittmann pGrfNd->ReleaseGraphicFromCache();
11688a2cae91SOliver-Rainer Wittmann }
11698a2cae91SOliver-Rainer Wittmann }
11708a2cae91SOliver-Rainer Wittmann }
1171cdf0e10cSrcweir }
1172cdf0e10cSrcweir
1173cdf0e10cSrcweir // returns the with our graphic attributes filled Graphic-Attr-Structure
GetGraphicAttr(GraphicAttr & rGA,const SwFrm * pFrm) const11748a2cae91SOliver-Rainer Wittmann GraphicAttr& SwGrfNode::GetGraphicAttr(
11758a2cae91SOliver-Rainer Wittmann GraphicAttr& rGA,
11768a2cae91SOliver-Rainer Wittmann const SwFrm* pFrm ) const
11778a2cae91SOliver-Rainer Wittmann {
11788a2cae91SOliver-Rainer Wittmann const SwAttrSet& rSet = GetSwAttrSet();
11798a2cae91SOliver-Rainer Wittmann
11808a2cae91SOliver-Rainer Wittmann rGA.SetDrawMode( (GraphicDrawMode) rSet.GetDrawModeGrf().GetValue() );
11818a2cae91SOliver-Rainer Wittmann
11828a2cae91SOliver-Rainer Wittmann const SwMirrorGrf & rMirror = rSet.GetMirrorGrf();
11838a2cae91SOliver-Rainer Wittmann sal_uLong nMirror = BMP_MIRROR_NONE;
11848a2cae91SOliver-Rainer Wittmann if ( rMirror.IsGrfToggle() && pFrm && !pFrm->FindPageFrm()->OnRightPage() )
11858a2cae91SOliver-Rainer Wittmann {
11868a2cae91SOliver-Rainer Wittmann switch (rMirror.GetValue())
11878a2cae91SOliver-Rainer Wittmann {
11888a2cae91SOliver-Rainer Wittmann case RES_MIRROR_GRAPH_DONT:
11898a2cae91SOliver-Rainer Wittmann nMirror = BMP_MIRROR_HORZ;
11908a2cae91SOliver-Rainer Wittmann break;
11918a2cae91SOliver-Rainer Wittmann case RES_MIRROR_GRAPH_VERT:
11928a2cae91SOliver-Rainer Wittmann nMirror = BMP_MIRROR_NONE;
11938a2cae91SOliver-Rainer Wittmann break;
11948a2cae91SOliver-Rainer Wittmann case RES_MIRROR_GRAPH_HOR:
11958a2cae91SOliver-Rainer Wittmann nMirror = BMP_MIRROR_HORZ | BMP_MIRROR_VERT;
11968a2cae91SOliver-Rainer Wittmann break;
11978a2cae91SOliver-Rainer Wittmann default:
11988a2cae91SOliver-Rainer Wittmann nMirror = BMP_MIRROR_VERT;
11998a2cae91SOliver-Rainer Wittmann break;
12008a2cae91SOliver-Rainer Wittmann }
12018a2cae91SOliver-Rainer Wittmann }
12028a2cae91SOliver-Rainer Wittmann else
12038a2cae91SOliver-Rainer Wittmann switch (rMirror.GetValue())
12048a2cae91SOliver-Rainer Wittmann {
12058a2cae91SOliver-Rainer Wittmann case RES_MIRROR_GRAPH_BOTH:
12068a2cae91SOliver-Rainer Wittmann nMirror = BMP_MIRROR_HORZ | BMP_MIRROR_VERT;
12078a2cae91SOliver-Rainer Wittmann break;
12088a2cae91SOliver-Rainer Wittmann case RES_MIRROR_GRAPH_VERT:
12098a2cae91SOliver-Rainer Wittmann nMirror = BMP_MIRROR_HORZ;
12108a2cae91SOliver-Rainer Wittmann break;
12118a2cae91SOliver-Rainer Wittmann case RES_MIRROR_GRAPH_HOR:
12128a2cae91SOliver-Rainer Wittmann nMirror = BMP_MIRROR_VERT;
12138a2cae91SOliver-Rainer Wittmann break;
12148a2cae91SOliver-Rainer Wittmann }
12158a2cae91SOliver-Rainer Wittmann
12168a2cae91SOliver-Rainer Wittmann rGA.SetMirrorFlags( nMirror );
12178a2cae91SOliver-Rainer Wittmann
12188a2cae91SOliver-Rainer Wittmann const SwCropGrf& rCrop = rSet.GetCropGrf();
12198a2cae91SOliver-Rainer Wittmann rGA.SetCrop( TWIP_TO_MM100( rCrop.GetLeft() ),
12208a2cae91SOliver-Rainer Wittmann TWIP_TO_MM100( rCrop.GetTop() ),
12218a2cae91SOliver-Rainer Wittmann TWIP_TO_MM100( rCrop.GetRight() ),
12228a2cae91SOliver-Rainer Wittmann TWIP_TO_MM100( rCrop.GetBottom() ) );
12238a2cae91SOliver-Rainer Wittmann
12248a2cae91SOliver-Rainer Wittmann const SwRotationGrf& rRotation = rSet.GetRotationGrf();
12258a2cae91SOliver-Rainer Wittmann rGA.SetRotation( rRotation.GetValue() );
12268a2cae91SOliver-Rainer Wittmann
12278a2cae91SOliver-Rainer Wittmann rGA.SetLuminance( rSet.GetLuminanceGrf().GetValue() );
12288a2cae91SOliver-Rainer Wittmann rGA.SetContrast( rSet.GetContrastGrf().GetValue() );
12298a2cae91SOliver-Rainer Wittmann rGA.SetChannelR( rSet.GetChannelRGrf().GetValue() );
12308a2cae91SOliver-Rainer Wittmann rGA.SetChannelG( rSet.GetChannelGGrf().GetValue() );
12318a2cae91SOliver-Rainer Wittmann rGA.SetChannelB( rSet.GetChannelBGrf().GetValue() );
12328a2cae91SOliver-Rainer Wittmann rGA.SetGamma( rSet.GetGammaGrf().GetValue() );
12338a2cae91SOliver-Rainer Wittmann rGA.SetInvert( rSet.GetInvertGrf().GetValue() );
12348a2cae91SOliver-Rainer Wittmann
12358a2cae91SOliver-Rainer Wittmann const sal_uInt16 nTrans = rSet.GetTransparencyGrf().GetValue();
12368a2cae91SOliver-Rainer Wittmann rGA.SetTransparency( (sal_uInt8) FRound(
12378a2cae91SOliver-Rainer Wittmann Min( nTrans, (sal_uInt16) 100 ) * 2.55 ) );
12388a2cae91SOliver-Rainer Wittmann
12398a2cae91SOliver-Rainer Wittmann return rGA;
1240cdf0e10cSrcweir }
1241cdf0e10cSrcweir
IsTransparent() const1242cdf0e10cSrcweir sal_Bool SwGrfNode::IsTransparent() const
1243cdf0e10cSrcweir {
12448a2cae91SOliver-Rainer Wittmann sal_Bool bRet = maGrfObj.IsTransparent();
12458a2cae91SOliver-Rainer Wittmann if ( !bRet ) // ask the attribut
12468a2cae91SOliver-Rainer Wittmann bRet = 0 != GetSwAttrSet().GetTransparencyGrf().GetValue();
1247cdf0e10cSrcweir
12488a2cae91SOliver-Rainer Wittmann return bRet;
1249cdf0e10cSrcweir }
1250cdf0e10cSrcweir
IsSelected() const1251cdf0e10cSrcweir sal_Bool SwGrfNode::IsSelected() const
1252cdf0e10cSrcweir {
12538a2cae91SOliver-Rainer Wittmann sal_Bool bRet = sal_False;
12548a2cae91SOliver-Rainer Wittmann const SwEditShell* pESh = GetDoc()->GetEditShell();
12558a2cae91SOliver-Rainer Wittmann if ( pESh )
12568a2cae91SOliver-Rainer Wittmann {
12578a2cae91SOliver-Rainer Wittmann const SwNode* pN = this;
12588a2cae91SOliver-Rainer Wittmann const ViewShell* pV = pESh;
12598a2cae91SOliver-Rainer Wittmann do
12608a2cae91SOliver-Rainer Wittmann {
12618a2cae91SOliver-Rainer Wittmann if ( pV->ISA( SwEditShell ) && pN == &( (SwCrsrShell*) pV )
12628a2cae91SOliver-Rainer Wittmann ->GetCrsr()->GetPoint()->nNode.GetNode() )
12638a2cae91SOliver-Rainer Wittmann {
12648a2cae91SOliver-Rainer Wittmann bRet = sal_True;
12658a2cae91SOliver-Rainer Wittmann break;
12668a2cae91SOliver-Rainer Wittmann }
12678a2cae91SOliver-Rainer Wittmann }
12688a2cae91SOliver-Rainer Wittmann while (pESh != ( pV = (ViewShell*) pV->GetNext() ));
12698a2cae91SOliver-Rainer Wittmann }
12708a2cae91SOliver-Rainer Wittmann return bRet;
1271cdf0e10cSrcweir }
1272cdf0e10cSrcweir
GetThreadConsumer()1273cdf0e10cSrcweir boost::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > SwGrfNode::GetThreadConsumer()
1274cdf0e10cSrcweir {
1275cdf0e10cSrcweir return mpThreadConsumer;
1276cdf0e10cSrcweir }
1277cdf0e10cSrcweir
TriggerAsyncRetrieveInputStream()1278cdf0e10cSrcweir void SwGrfNode::TriggerAsyncRetrieveInputStream()
1279cdf0e10cSrcweir {
1280cdf0e10cSrcweir if ( !IsLinkedFile() )
1281cdf0e10cSrcweir {
1282cdf0e10cSrcweir ASSERT( false,
12838a2cae91SOliver-Rainer Wittmann "<SwGrfNode::TriggerAsyncLoad()> - Method is misused. Method call is only valid for graphic nodes, which refer a linked graphic file" );
1284cdf0e10cSrcweir return;
1285cdf0e10cSrcweir }
1286cdf0e10cSrcweir
1287cdf0e10cSrcweir if ( mpThreadConsumer.get() == 0 )
1288cdf0e10cSrcweir {
1289cdf0e10cSrcweir mpThreadConsumer.reset( new SwAsyncRetrieveInputStreamThreadConsumer( *this ) );
1290cdf0e10cSrcweir
1291cdf0e10cSrcweir String sGrfNm;
1292cdf0e10cSrcweir refLink->GetLinkManager()->GetDisplayNames( refLink, 0, &sGrfNm, 0, 0 );
1293cdf0e10cSrcweir
1294cdf0e10cSrcweir mpThreadConsumer->CreateThread( sGrfNm );
1295cdf0e10cSrcweir }
1296cdf0e10cSrcweir }
1297cdf0e10cSrcweir
IsLinkedInputStreamReady() const1298cdf0e10cSrcweir bool SwGrfNode::IsLinkedInputStreamReady() const
1299cdf0e10cSrcweir {
1300cdf0e10cSrcweir return mbLinkedInputStreamReady;
1301cdf0e10cSrcweir }
1302cdf0e10cSrcweir
ApplyInputStream(com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xInputStream,const sal_Bool bIsStreamReadOnly)1303cdf0e10cSrcweir void SwGrfNode::ApplyInputStream(
13048a2cae91SOliver-Rainer Wittmann com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xInputStream,
1305cdf0e10cSrcweir const sal_Bool bIsStreamReadOnly )
1306cdf0e10cSrcweir {
1307cdf0e10cSrcweir if ( IsLinkedFile() )
1308cdf0e10cSrcweir {
1309cdf0e10cSrcweir if ( xInputStream.is() )
1310cdf0e10cSrcweir {
1311cdf0e10cSrcweir mxInputStream = xInputStream;
1312cdf0e10cSrcweir mbIsStreamReadOnly = bIsStreamReadOnly;
1313cdf0e10cSrcweir mbLinkedInputStreamReady = true;
1314cdf0e10cSrcweir SwMsgPoolItem aMsgHint( RES_LINKED_GRAPHIC_STREAM_ARRIVED );
1315cdf0e10cSrcweir ModifyNotification( &aMsgHint, &aMsgHint );
1316cdf0e10cSrcweir }
1317cdf0e10cSrcweir }
1318cdf0e10cSrcweir }
1319cdf0e10cSrcweir
UpdateLinkWithInputStream()1320cdf0e10cSrcweir void SwGrfNode::UpdateLinkWithInputStream()
1321cdf0e10cSrcweir {
1322cdf0e10cSrcweir // do not work on link, if a <SwapIn> has been triggered.
1323cdf0e10cSrcweir if ( !bInSwapIn && IsLinkedFile() )
1324cdf0e10cSrcweir {
1325cdf0e10cSrcweir GetLink()->setStreamToLoadFrom( mxInputStream, mbIsStreamReadOnly );
1326cdf0e10cSrcweir GetLink()->Update();
1327cdf0e10cSrcweir SwMsgPoolItem aMsgHint( RES_GRAPHIC_ARRIVED );
1328cdf0e10cSrcweir ModifyNotification( &aMsgHint, &aMsgHint );
1329cdf0e10cSrcweir
1330cdf0e10cSrcweir mxInputStream.clear();
1331cdf0e10cSrcweir GetLink()->clearStreamToLoadFrom();
1332cdf0e10cSrcweir mbLinkedInputStreamReady = false;
1333cdf0e10cSrcweir mpThreadConsumer.reset();
1334cdf0e10cSrcweir }
1335cdf0e10cSrcweir }
1336cdf0e10cSrcweir
13378a2cae91SOliver-Rainer Wittmann
IsAsyncRetrieveInputStreamPossible() const1338cdf0e10cSrcweir bool SwGrfNode::IsAsyncRetrieveInputStreamPossible() const
1339cdf0e10cSrcweir {
1340cdf0e10cSrcweir bool bRet = false;
1341cdf0e10cSrcweir
1342cdf0e10cSrcweir if ( IsLinkedFile() )
1343cdf0e10cSrcweir {
1344cdf0e10cSrcweir String sGrfNm;
1345cdf0e10cSrcweir refLink->GetLinkManager()->GetDisplayNames( refLink, 0, &sGrfNm, 0, 0 );
1346cdf0e10cSrcweir String sProtocol( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.pkg:" ) );
1347cdf0e10cSrcweir if ( sGrfNm.CompareTo( sProtocol, sProtocol.Len() ) != 0 )
1348cdf0e10cSrcweir {
1349cdf0e10cSrcweir bRet = true;
1350cdf0e10cSrcweir }
1351cdf0e10cSrcweir }
1352cdf0e10cSrcweir
1353cdf0e10cSrcweir return bRet;
1354cdf0e10cSrcweir }
1355