LibreOffice Module sw (master)  1
sdrhhcwrap.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <svx/svdotext.hxx>
21 #include <svx/svdpagv.hxx>
22 #include <sfx2/printer.hxx>
23 #include <svx/svdview.hxx>
24 #include <drawdoc.hxx>
25 #include "sdrhhcwrap.hxx"
26 #include <docsh.hxx>
27 #include <wrtsh.hxx>
28 #include <view.hxx>
29 #include <dcontact.hxx>
30 #include <doc.hxx>
33 #include <edtwin.hxx>
34 
35 using namespace ::com::sun::star;
36 
38  LanguageType nSourceLanguage, LanguageType nTargetLanguage,
39  const vcl::Font* pTargetFnt,
40  sal_Int32 nConvOptions,
41  bool bInteractive ) :
42  SdrOutliner(pVw->GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->
43  GetDrawOutliner().GetEmptyItemSet().GetPool(),
45  pView( pVw ),
46  pTextObj( nullptr ),
47  nOptions( nConvOptions ),
48  nDocIndex( 0 ),
49  nSourceLang( nSourceLanguage ),
50  nTargetLang( nTargetLanguage ),
51  pTargetFont( pTargetFnt ),
52  bIsInteractive( bInteractive )
53 {
54  SetRefDevice( pView->GetDocShell()->GetDoc()->getIDocumentDeviceAccess().getPrinter( false ) );
55 
56  MapMode aMapMode (MapUnit::MapTwip);
57  SetRefMapMode(aMapMode);
58 
59  Size aSize( 1, 1 );
60  SetPaperSize( aSize );
61 
62  pOutlView.reset( new OutlinerView( this, &(pView->GetEditWin()) ) );
63  pOutlView->GetOutliner()->SetRefDevice(pView->GetWrtShell().getIDocumentDeviceAccess().getPrinter( false ));
64 
65  // Hack: all SdrTextObj attributes should be transferred to EditEngine
66  pOutlView->SetBackgroundColor( COL_WHITE );
67 
68  InsertView( pOutlView.get() );
69  Point aPoint( 0, 0 );
70  tools::Rectangle aRect( aPoint, aSize );
71  pOutlView->SetOutputArea( aRect );
72 // SetText( NULL );
73  ClearModifyFlag();
74 }
75 
77 {
78  if (pTextObj)
79  {
80  SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
81  OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
82  pSdrView->SdrEndTextEdit( true );
83  SetUpdateMode(false);
84  pOutlView->SetOutputArea( tools::Rectangle( Point(), Size(1, 1) ) );
85  }
86  RemoveView( pOutlView.get() );
87  pOutlView.reset();
88 }
89 
91 {
92  pOutlView->StartTextConversion( nSourceLang, nTargetLang, pTargetFont, nOptions, bIsInteractive, true );
93 }
94 
96 {
97  bool bNextDoc = false;
98 
99  if ( pTextObj )
100  {
101  SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
102  OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
103  pSdrView->SdrEndTextEdit( true );
104  SetUpdateMode(false);
105  pOutlView->SetOutputArea( tools::Rectangle( Point(), Size(1, 1) ) );
106  SetPaperSize( Size(1, 1) );
107  Clear();
108  pTextObj = nullptr;
109  }
110 
111  const auto n = nDocIndex;
112 
113  std::list<SdrTextObj*> aTextObjs;
115  for (auto const& textObj : aTextObjs)
116  {
117  pTextObj = textObj;
118  if (textObj)
119  {
120  OutlinerParaObject* pParaObj = textObj->GetOutlinerParaObject();
121  if ( pParaObj )
122  {
123  SetPaperSize( textObj->GetLogicRect().GetSize() );
124  SetText( *pParaObj );
125 
126  ClearModifyFlag();
127 
133  SetUpdateMode(true);
134  if (HasConvertibleTextPortion( nSourceLang ))
135  {
136  SdrView *pSdrView = pView->GetWrtShell().GetDrawView();
137  OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
138  SdrPageView* pPV = pSdrView->GetSdrPageView();
139  nDocIndex = n;
140  bNextDoc = true;
141  pOutlView->SetOutputArea( tools::Rectangle( Point(), Size(1,1)));
143  SetUpdateMode(true);
145 
146  pSdrView->SdrBeginTextEdit(pTextObj, pPV, &pView->GetEditWin(), false, this, pOutlView.get(), true, true);
147  }
148  else
149  SetUpdateMode(false);
150  }
151 
152  if ( !bNextDoc )
153  pTextObj = nullptr;
154  else
155  break;
156  }
157  }
158 
159  ClearModifyFlag();
160 
161  return bNextDoc;
162 }
163 
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OutlinerMode
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false)
SdrView * GetDrawView()
Definition: vnew.cxx:375
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:237
sal_Int64 n
SwEditWin & GetEditWin()
Definition: view.hxx:403
const vcl::Font * pTargetFont
Definition: sdrhhcwrap.hxx:39
SwWrtShell & GetWrtShell() const
Definition: view.hxx:400
std::unique_ptr< OutlinerView > pOutlView
Definition: sdrhhcwrap.hxx:34
void MakeVisible(const SwRect &)
Definition: viewsh.cxx:567
LanguageType nSourceLang
Definition: sdrhhcwrap.hxx:37
SwDoc * GetDoc()
returns Doc. But be careful!
Definition: docsh.hxx:203
const IDocumentDeviceAccess & getIDocumentDeviceAccess() const
Provides access to the document device interface.
Definition: viewsh.cxx:2587
LanguageType nTargetLang
Definition: sdrhhcwrap.hxx:38
virtual bool SdrBeginTextEdit(SdrObject *pObj, SdrPageView *pPV=nullptr, vcl::Window *pWin=nullptr, bool bIsNewObj=false, SdrOutliner *pGivenOutliner=nullptr, OutlinerView *pGivenOutlinerView=nullptr, bool bDontDeleteOutliner=false, bool bOnlyOneView=false, bool bGrabFocus=true)
virtual SfxPrinter * getPrinter(bool bCreate) const =0
Return the printer set at the document.
sal_uInt16 nDocIndex
Definition: sdrhhcwrap.hxx:36
SdrHHCWrapper(SwView *pVw, LanguageType nSourceLanguage, LanguageType nTargetLanguage, const vcl::Font *pTargetFnt, sal_Int32 nConvOptions, bool bInteractive)
Definition: sdrhhcwrap.cxx:37
Size GetSize() const
SwDocShell * GetDocShell()
Definition: view.cxx:1107
bool bIsInteractive
Definition: sdrhhcwrap.hxx:40
void StartTextConversion()
Definition: sdrhhcwrap.cxx:90
SwView * pView
Definition: sdrhhcwrap.hxx:32
SdrTextObj * pTextObj
Definition: sdrhhcwrap.hxx:33
sal_Int32 nOptions
Definition: sdrhhcwrap.hxx:35
constexpr::Color COL_WHITE(0xFF, 0xFF, 0xFF)
SdrPageView * GetSdrPageView() const
static void GetTextObjectsFromFormat(std::list< SdrTextObj * > &, SwDoc *)
get data collection of anchored objects, handled by with contact
Definition: dcontact.cxx:730
virtual ~SdrHHCWrapper() override
Definition: sdrhhcwrap.cxx:76
virtual bool ConvertNextDocument() override
Definition: sdrhhcwrap.cxx:95
Definition: view.hxx:146
virtual const tools::Rectangle & GetLogicRect() const override